MySQL Forums
Forum List  »  German

Re: Performance bei SELECT
Posted by: Mark Knochen
Date: January 25, 2012 11:11PM

Hallo,

ja, die Mehrfachberechnungen stören mich auch - allerdings sah ich bislang keine Möglichkeit, auf ein einmal berechnetes Ergebnis z.B. per Variable im Query zuzugreifen.

Beim Datenmodell ist sicher nicht alles optimal, was aber die Verknüpfungen der Tabellen untereinander angeht - da bin ich doch recht zuversichtlich, dass es so ok ist.

Es wäre vermutlich viel gewonnen, wenn man die Mehrfachberechnungen nur jeweils einmal machen müsste und dann auf diesen Wert zugreifen könnte.

Ich strukturiere gerade nebenbei noch den kompletten Query um, so dass die invoicelines nicht per LEFT JOIN kommen, sondern in einzelnen SubSelects - das löst auch das GROUP BY Problem.


Hier mal der EXPLAIN für den gesamten String:


+----+--------------------+--------------+------+---------------+-----------+---------+--------------------------------+--------+---------------------------------+
| id | select_type        | table        | type | possible_keys | key       | key_len | ref                            | rows   | Extra                           |
+----+--------------------+--------------+------+---------------+-----------+---------+--------------------------------+--------+---------------------------------+
|  1 | PRIMARY            | items        | ALL  | NULL          | NULL      | NULL    | NULL                           |  72176 | Using temporary; Using filesort |
|  1 | PRIMARY            | <derived15>  | ALL  | NULL          | NULL      | NULL    | NULL                           |  39683 |                                 |
| 15 | DERIVED            | invoicelines | ALL  | NULL          | NULL      | NULL    | NULL                           | 551160 | Using temporary                 |
| 14 | DEPENDENT SUBQUERY | items_stock  | ref  | ItemNrInt     | ItemNrInt | 4       | reporting_test.items.ItemNrInt |      8 | Using where                     |
| 13 | DEPENDENT SUBQUERY | items_stock  | ref  | ItemNrInt     | ItemNrInt | 4       | reporting_test.items.ItemNrInt |      8 | Using where                     |
| 12 | DEPENDENT SUBQUERY | items_stock  | ref  | ItemNrInt     | ItemNrInt | 4       | reporting_test.items.ItemNrInt |      8 | Using where                     |
| 11 | DEPENDENT SUBQUERY | items_stock  | ref  | ItemNrInt     | ItemNrInt | 4       | reporting_test.items.ItemNrInt |      8 | Using where                     |
| 10 | DEPENDENT SUBQUERY | items_stock  | ref  | ItemNrInt     | ItemNrInt | 4       | reporting_test.items.ItemNrInt |      8 | Using where                     |
|  9 | DEPENDENT SUBQUERY | so           | ALL  | ItemNrInt     | NULL      | NULL    | NULL                           |   1333 | Using where                     |
|  8 | DEPENDENT SUBQUERY | items_stock  | ref  | ItemNrInt     | ItemNrInt | 4       | reporting_test.items.ItemNrInt |      8 | Using where                     |
|  7 | DEPENDENT SUBQUERY | items_stock  | ref  | ItemNrInt     | ItemNrInt | 4       | reporting_test.items.ItemNrInt |      8 | Using where                     |
|  6 | DEPENDENT SUBQUERY | items_stock  | ref  | ItemNrInt     | ItemNrInt | 4       | reporting_test.items.ItemNrInt |      8 | Using where                     |
|  5 | DEPENDENT SUBQUERY | items_stock  | ref  | ItemNrInt     | ItemNrInt | 4       | reporting_test.items.ItemNrInt |      8 | Using where                     |
|  4 | DEPENDENT SUBQUERY | items_stock  | ref  | ItemNrInt     | ItemNrInt | 4       | reporting_test.items.ItemNrInt |      8 | Using where                     |
|  3 | DEPENDENT SUBQUERY | items_stock  | ref  | ItemNrInt     | ItemNrInt | 4       | reporting_test.items.ItemNrInt |      8 | Using where                     |
|  2 | DEPENDENT SUBQUERY | items_stock  | ref  | ItemNrInt     | ItemNrInt | 4       | reporting_test.items.ItemNrInt |      8 | Using where                     |
+----+--------------------+--------------+------+---------------+-----------+---------+--------------------------------+--------+---------------------------------+

Grüße


Mark

Options: ReplyQuote


Subject
Views
Written By
Posted
2602
January 19, 2012 07:17AM
1451
January 19, 2012 12:59PM
1518
January 20, 2012 05:33AM
1734
January 20, 2012 06:10AM
1462
January 20, 2012 07:06AM
1477
January 20, 2012 12:11PM
1438
January 25, 2012 04:11AM
1303
January 25, 2012 04:24AM
1356
January 25, 2012 04:30AM
1282
January 25, 2012 04:49AM
1118
January 25, 2012 06:05AM
1408
January 25, 2012 06:37AM
1386
January 25, 2012 07:46AM
1457
January 26, 2012 12:57AM
Re: Performance bei SELECT
1361
January 25, 2012 11:11PM
1236
January 25, 2012 11:50PM
1141
January 27, 2012 08:27AM
1538
January 27, 2012 06:21AM
1377
February 02, 2012 10:06PM
1085
February 03, 2012 05:34AM
1340
February 03, 2012 02:04PM
1270
February 08, 2012 09:52PM
1317
February 09, 2012 08:41AM
1226
February 10, 2012 02:03AM
1479
February 10, 2012 02:52AM
1372
February 10, 2012 04:51AM
1341
February 09, 2012 11:58PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.