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
2611
January 19, 2012 07:17AM
1457
January 19, 2012 12:59PM
1526
January 20, 2012 05:33AM
1741
January 20, 2012 06:10AM
1469
January 20, 2012 07:06AM
1481
January 20, 2012 12:11PM
1443
January 25, 2012 04:11AM
1309
January 25, 2012 04:24AM
1361
January 25, 2012 04:30AM
1290
January 25, 2012 04:49AM
1124
January 25, 2012 06:05AM
1412
January 25, 2012 06:37AM
1389
January 25, 2012 07:46AM
1471
January 26, 2012 12:57AM
Re: Performance bei SELECT
1367
January 25, 2012 11:11PM
1242
January 25, 2012 11:50PM
1149
January 27, 2012 08:27AM
1542
January 27, 2012 06:21AM
1382
February 02, 2012 10:06PM
1094
February 03, 2012 05:34AM
1347
February 03, 2012 02:04PM
1277
February 08, 2012 09:52PM
1322
February 09, 2012 08:41AM
1233
February 10, 2012 02:03AM
1483
February 10, 2012 02:52AM
1378
February 10, 2012 04:51AM
1345
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.