Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial mysql执行多表查询,大数据,sql该怎么写。

mysql执行多表查询,大数据,sql该怎么写。

Jun 23, 2016 pm 02:25 PM

假设两个表   A  B。两个表结构相同。现在要取出A表的所有字段和B表的set,rutime字段。两个表的ID相同。   

因为数据量比较大,两个表在100w左右,之后还可能会有多个这样大的表。
我在phpmyadmin中拿

select * from A as a,B as b where a.haoma = b.haoma

测试的时候就已经跑死掉了。哪位大虾帮助写一下这个sql


回复讨论(解决方案)

select ecs_ershi.* ,ecs_erjiu.set from ecs_ershi inner join ecs_erjiu on ecs_ershi.haoma=ecs_erjiu.haoma limit 0,29
Copy after login

我写了这个语句,查询成功了。但是数据量一大,就死在那了。 
我想将查询出来的数据存储到C表,有什么好方法可以?

does it has indexes on A.haoma and B.haoma?

does it has indexes on A.haoma and B.haoma?
亲,可以解释下什么意思不。

A.haoma 与 B.haoma 建索引了吗?

不建索引,作死!!!

haoma 是主键么,如果不是的话建立索引试试。

select * from A as a,B as b where a.haoma = b.haoma
只要在 haoma 上都建有索引,查询只是瞬间的事情
但是输出可是要很花一些时间的!
你把100万条记录都打印出来吗?显然是脑袋有毛病了

直接
insert into c(......) 
select ecs_ershi.* ,ecs_erjiu.set 
from ecs_ershi inner join ecs_erjiu on ecs_ershi.haoma=ecs_erjiu.haoma 
limit 0,29
即可, 

不要输出。。。

select * from A as a,B as b where a.haoma = b.haoma
只要在 haoma 上都建有索引,查询只是瞬间的事情
但是输出可是要很花一些时间的!
你把100万条记录都打印出来吗?显然是脑袋有毛病了
膜拜大神,我是来拿分的。

select * from A as a,B as b where a.haoma = b.haoma
只要在 haoma 上都建有索引,查询只是瞬间的事情
但是输出可是要很花一些时间的!
你把100万条记录都打印出来吗?显然是脑袋有毛病了
那查询出来之后除了做分页处理之后还能做什么比较快速的可以打印出来。

这个应该体现出来索引的作用了。查询上百万条的记录很慢了。

1.上面说的,建立有效的索引
2.如果数据量以后还会增加的话建立分表
3.表的结构涉及到字符比较长的独立出来新表中
4.查询使用存储过程来实现

phpmyadmin执行多了卡死(php.ini中设置set_time_limit(0);),可以试着用navicate for mysql

desc select * from A as a,B as b where a.haoma = b.haoma给表加上索引,就很快的,如果有where条件查询,可以加上全文索引。

Statement of this Website
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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP's big data structure processing skills PHP's big data structure processing skills May 08, 2024 am 10:24 AM

Big data structure processing skills: Chunking: Break down the data set and process it in chunks to reduce memory consumption. Generator: Generate data items one by one without loading the entire data set, suitable for unlimited data sets. Streaming: Read files or query results line by line, suitable for large files or remote data. External storage: For very large data sets, store the data in a database or NoSQL.

C++ development experience sharing: Practical experience in C++ big data programming C++ development experience sharing: Practical experience in C++ big data programming Nov 22, 2023 am 09:14 AM

In the Internet era, big data has become a new resource. With the continuous improvement of big data analysis technology, the demand for big data programming has become more and more urgent. As a widely used programming language, C++’s unique advantages in big data programming have become increasingly prominent. Below I will share my practical experience in C++ big data programming. 1. Choosing the appropriate data structure Choosing the appropriate data structure is an important part of writing efficient big data programs. There are a variety of data structures in C++ that we can use, such as arrays, linked lists, trees, hash tables, etc.

Five major development trends in the AEC/O industry in 2024 Five major development trends in the AEC/O industry in 2024 Apr 19, 2024 pm 02:50 PM

AEC/O (Architecture, Engineering & Construction/Operation) refers to the comprehensive services that provide architectural design, engineering design, construction and operation in the construction industry. In 2024, the AEC/O industry faces changing challenges amid technological advancements. This year is expected to see the integration of advanced technologies, heralding a paradigm shift in design, construction and operations. In response to these changes, industries are redefining work processes, adjusting priorities, and enhancing collaboration to adapt to the needs of a rapidly changing world. The following five major trends in the AEC/O industry will become key themes in 2024, recommending it move towards a more integrated, responsive and sustainable future: integrated supply chain, smart manufacturing

Application of algorithms in the construction of 58 portrait platform Application of algorithms in the construction of 58 portrait platform May 09, 2024 am 09:01 AM

1. Background of the Construction of 58 Portraits Platform First of all, I would like to share with you the background of the construction of the 58 Portrait Platform. 1. The traditional thinking of the traditional profiling platform is no longer enough. Building a user profiling platform relies on data warehouse modeling capabilities to integrate data from multiple business lines to build accurate user portraits; it also requires data mining to understand user behavior, interests and needs, and provide algorithms. side capabilities; finally, it also needs to have data platform capabilities to efficiently store, query and share user profile data and provide profile services. The main difference between a self-built business profiling platform and a middle-office profiling platform is that the self-built profiling platform serves a single business line and can be customized on demand; the mid-office platform serves multiple business lines, has complex modeling, and provides more general capabilities. 2.58 User portraits of the background of Zhongtai portrait construction

Discussion on the reasons and solutions for the lack of big data framework in Go language Discussion on the reasons and solutions for the lack of big data framework in Go language Mar 29, 2024 pm 12:24 PM

In today's big data era, data processing and analysis have become an important support for the development of various industries. As a programming language with high development efficiency and superior performance, Go language has gradually attracted attention in the field of big data. However, compared with other languages ​​such as Java and Python, Go language has relatively insufficient support for big data frameworks, which has caused trouble for some developers. This article will explore the main reasons for the lack of big data framework in Go language, propose corresponding solutions, and illustrate it with specific code examples. 1. Go language

Getting Started Guide: Using Go Language to Process Big Data Getting Started Guide: Using Go Language to Process Big Data Feb 25, 2024 pm 09:51 PM

As an open source programming language, Go language has gradually received widespread attention and use in recent years. It is favored by programmers for its simplicity, efficiency, and powerful concurrent processing capabilities. In the field of big data processing, the Go language also has strong potential. It can be used to process massive data, optimize performance, and can be well integrated with various big data processing tools and frameworks. In this article, we will introduce some basic concepts and techniques of big data processing in Go language, and show how to use Go language through specific code examples.

AI, digital twins, visualization... Highlights of the 2023 Yizhiwei Autumn Product Launch Conference! AI, digital twins, visualization... Highlights of the 2023 Yizhiwei Autumn Product Launch Conference! Nov 14, 2023 pm 05:29 PM

Yizhiwei’s 2023 autumn product launch has concluded successfully! Let us review the highlights of the conference together! 1. Intelligent inclusive openness, allowing digital twins to become productive Ning Haiyuan, co-founder of Kangaroo Cloud and CEO of Yizhiwei, said in his opening speech: At this year’s company’s strategic meeting, we positioned the main direction of product research and development as “intelligent inclusive openness” "Three core capabilities, focusing on the three core keywords of "intelligent inclusive openness", we further proposed the development goal of "making digital twins a productive force". 2. EasyTwin: Explore a new digital twin engine that is easier to use 1. From 0.1 to 1.0, continue to explore the digital twin fusion rendering engine to have better solutions with mature 3D editing mode, convenient interactive blueprints, and massive model assets

Big data processing in C++ technology: How to use in-memory databases to optimize big data performance? Big data processing in C++ technology: How to use in-memory databases to optimize big data performance? May 31, 2024 pm 07:34 PM

In big data processing, using an in-memory database (such as Aerospike) can improve the performance of C++ applications because it stores data in computer memory, eliminating disk I/O bottlenecks and significantly increasing data access speeds. Practical cases show that the query speed of using an in-memory database is several orders of magnitude faster than using a hard disk database.

See all articles