union all效率低下,大概union all数十张表,单表select仅需0.0003-0.002秒,但union all后需要0.6秒左右
想改善下效率
这种情况该用存储过程、视图、临时表哪种方法来解决?
回复讨论(解决方案)
很明显,你的数据组织的不合理
很明显,你的数据组织的不合理
难道从来不会有这种情况发生吗
组织合理就没有这种情况
你把同类数据垂直分配在数十个表中,就是不合理
组织合理就没有这种情况
你把同类数据垂直分配在数十个表中,就是不合理
这些表的结构不完全相同的。当时就是考虑到放在一张表会复杂。所以就分开了。不过后来发现要汇总时,问题就来了。
大家有没有好的办法。之前建立的那些表已经应用到一些功能上了。现在改也太大工程了。
你能说一下你的那些表的结构吗?
既然并不相同,那么叠加在一起的意义何在?
你能说一下你的那些表的结构吗?
既然并不相同,那么叠加在一起的意义何在?
我刚刚查了一下,7个表,分别是
1.销售凭证、红字销售凭证
2.采购凭证、红字采购凭证
3.收款凭证、付款凭证、转账凭证。
其中1组和2组结构是一样的,1组和2组只有一个字段不同。
3组中的收款凭证和付款凭证也是只有一字段不同,转账凭证的结构则是被收款凭证和付款凭证所包含。
补充一下,1组和2组各自内部的表结构是一样的。1组和2组之间只有一个字段不同。
1组和2组不同的字段是,
1组有‘销售单号、客户编码‘。
2组有 ’采购单号、供应商编码’。
1组和2组的表结构是这样,能合并成一个表吗?
数据量有多大啊?要达到分表的情况下了。分表的话,这种水平分也不合理吧。
你用 union 这不就对了!
这7个表是平行的,就算要连接也只能是 join
数据量有多大啊?要达到分表的情况下了。分表的话,这种水平分也不合理吧。
其实它们都是描述不同的东西。所以才分表的。
1.销售凭证、红字销售凭证
2.采购凭证、红字采购凭证
3.收款凭证、付款凭证、转账凭证。
你用 union 这不就对了!
这7个表是平行的,就算要连接也只能是 join
将1、2组表结构合并,3组表结构合并,这样合理么。
不必了吧?你不是说已经应用到一些功能上了吗?
不必了吧?你不是说已经应用到一些功能上了吗?
就是各自的一个增删查改的功能。我不知道这样设计,以后会不会有其它不好处理的地方出现。
愿意的话,你可以描述一下业务流程
刚刚那7个表是接下来要做的几个功能的数据来源。
比如,有一个日记账的功能,这个功能就是要从刚刚那7个表中的记录搜索有“银行存款和现金”这两个科目存在的明细记录。要把有这两个存的的明细都抽出来,然后汇总显示。
第二个,明细账功能,这个也是要从刚刚那7个表中搜索除了“银行存款和现金”以外的所有科目存在的明细记录,汇总显示。
第三个,科目汇总表,这个是在一定时间范围内,所有凭证按科目汇总。
第四个,总分类账,就是显示每个科目发生的所有明细记录。
可能描述的不是很好。请见谅。
union all 之后还做了order之类? 要不不该差这么大啊

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

PHP logging is essential for monitoring and debugging web applications, as well as capturing critical events, errors, and runtime behavior. It provides valuable insights into system performance, helps identify issues, and supports faster troubleshoot

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Laravel simplifies HTTP verb handling in incoming requests, streamlining diverse operation management within your applications. The method() and isMethod() methods efficiently identify and validate request types. This feature is crucial for building

The Storage::download method of the Laravel framework provides a concise API for safely handling file downloads while managing abstractions of file storage. Here is an example of using Storage::download() in the example controller:


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
