search
Homephp教程php手册php页面查询

php页面查询

Jun 06, 2016 pm 07:59 PM
phplarge scaledataInquireComparequestionpage

初次涉及到大规模数据的查询问题。用比较简单的方法处理了一下。 问题描述:目前有一个40G的文件,这个文件的每一行的组成都是一样的, id 以及此id对应的数据内容。一共数据约1.3亿条。 要求,输入一个id,能够快速查找到此id所对应的内容。 简单的解决方法

初次涉及到大规模数据的查询问题。用比较简单的方法处理了一下。

问题描述:目前有一个40G的文件,这个文件的每一行的组成都是一样的, id 以及此id对应的数据内容。一共数据约1.3亿条。

要求,输入一个id,能够快速查找到此id所对应的内容。


简单的解决方法:先根据id,把数据分到1000个文件中去,即 id%1000 ,这种方法相对比较简单。

由于可能数据不是完全离散分布的,有的文件可能有80多M。所以当给定id时,就可以直接定位到它所在的文件。

使用php进行查找时,我们可以使用正则表达式。把文件读入到一个字符串中,然后使用正则表达式进行匹配即可。

正则为:  "/".$id.".+\n/"


Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.