![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
After rebuilding my database, when I run reports against the new rebuilt database, the report which was taking 1 hour 40 mins before is now taking less than 2 mins to give results. But, this lasts for only 6-7 times the report is fetched. When I run the report for the 8th time, again it starts taking more than an hour. I just dont understand how can this happen... the same report which pops up in less than a min now is again taking more than an hour whereas no change has been done after the rebuild. In the documentation for ASA7, its mentioned that rebuilding offers performance gains and defrags space and indexes and this is what I also learnt on this forum as well. But how can the effect last for only 5-6 times the report is run. |
#3
| |||
| |||
|
|
How is the report created? Does it involve only SELECT statements, or does it also include INSERT, UPDATE and/or DELETE operations? Sometimes people create complex reports with complex logic that copies data around from table to table, stuff like that. It is not easy to solve a problem like yours using a forum like this... interactions are slow, so please be patient. Breck Thinks There Should Be Some Better Way Of Doing This On 17 Nov 2009 01:46:01 -0800, Deepali wrote: After rebuilding my database, when I run reports against the >new rebuilt database, the report which was taking 1 hour 40 >mins before is now taking less than 2 mins to give results. But, this lasts for only 6-7 times the report is fetched. When I run the report for the 8th time, again it starts taking more than an hour. I just dont understand how can this happen... the same report which pops up in less than a min now is again taking >more than an hour whereas no change has been done after the >rebuild. In the documentation for ASA7, its mentioned that rebuilding >offers performance gains and defrags space and indexes and >this is what I also learnt on this forum as well. But how can the effect last for only 5-6 times the report is >run. -- Breck Carter - Blog: http://sqlanywhere.blogspot.com/ SQLA questions and answers: http://sqla.stackexchange.com RisingRoad helps SQL Anywhere developers make better databases http://www.risingroad.com/ Breck.Carter at gmail |
#4
| |||
| |||
|
|
How is the report created? Does it involve only SELECT statements, or does it also include INSERT, UPDATE and/or DELETE operations? Sometimes people create complex reports with complex logic that copies data around from table to table, stuff like that. It is not easy to solve a problem like yours using a forum like this... interactions are slow, so please be patient. Breck Thinks There Should Be Some Better Way Of Doing This On 17 Nov 2009 01:46:01 -0800, Deepali wrote: After rebuilding my database, when I run reports against the new *rebuilt database, the report which was taking 1 hour 40 mins before is now taking less than 2 mins to give results. But, this lasts for only 6-7 times the report is fetched. When I run the report for the 8th time, again it starts taking more than an hour. I just dont understand how can this happen... the same report which pops up in less than a min now is again taking more than an hour whereas no change has been done after the rebuild. In the documentation for ASA7, its mentioned that rebuilding offers performance gains and defrags space and indexes and this is what I also learnt on this forum as well. But how can the effect last for only 5-6 times the report is run. -- Breck Carter - Blog:http://sqlanywhere.blogspot.com/ SQLA questions and answers:http://sqla.stackexchange.com RisingRoad helps SQL Anywhere developers make better databaseshttp://www.risingroad.com/ Breck.Carter at gmail |
#5
| |||
| |||
|
|
I detected this in ASA7 version and still happened in SA11 version. So my instruction to our programmers is : DO NOT USE ONLY JOIN in select command, USE JOIN .. ON ... !!!!! |
#6
| |||
| |||
|
|
Bofcilo wrote: I detected this in ASA7 version and still happened in SA11 version. So my instruction to our programmers is : DO NOT USE ONLY JOIN in select command, USE JOIN .. ON ... !!!!! IMHO, each JOIN that is not a NATURAL JOIN, a KEY JOIN or a CROSS JOIN *must* use an ON clause to specify the join condition. Otherwise the JOIN keywords seems quite useless. It seems that SA accepts the mere "JOIN" when there are FKs between the tables (and so might use a KEY JOIN silently). Call it a bug or a feature... When there are no FKs between the table, an error is raised. (Tested on ASA 8.0.3.5574 and 11.0.1.2331). I frankly use KEY JOINs quite often as the syntax is handy, but have never had performance problems with those joins. HTH Volker |
other situation query optimizer use FK
#7
| |||
| |||
|
|
On Nov 18, 10:28 am, Volker Barth <No_VBarth (AT) Spam_GLOBAL-FINANZ (DOT) de wrote: Bofcilo wrote: I detected this in ASA7 version and still happened in SA11 version. So my instruction to our programmers is : DO NOT USE ONLY JOIN in select command, USE JOIN .. ON ... !!!!! IMHO, each JOIN that is not a NATURAL JOIN, a KEY JOIN or a CROSS JOIN *must* use an ON clause to specify the join condition. Otherwise the JOIN keywords seems quite useless. It seems that SA accepts the mere "JOIN" when there are FKs between the tables (and so might use a KEY JOIN silently). Call it a bug or a feature... When there are no FKs between the table, an error is raised. (Tested on ASA 8.0.3.5574 and 11.0.1.2331). I frankly use KEY JOINs quite often as the syntax is handy, but have never had performance problems with those joins. HTH Volker Ok, i have to add more about this. First, I know for KEY JOIN and existing FKs between tables. I don't write about bug. I confirm that we detect problem in query optimizer in very specific situation. For many months one query on customer location work fine, fast. And then start slow execution. We tested that query in iSql and there found different query plan between fast and slow execution. Again, SAME query without any changes did work fast. First solution was drop statitistic (something like that i forgot). After that query work fast, and after some days again slow. Then we try (it is not needed) with rewriting query. ON clause was added in JOIN between master and detail tables and for many, many years works fine. This is happened in ASA7. Ok, it was first time, but believe me or not, there was in other app and situations. Something has been repeat. It is happened only IF master table has foreign key on column and one value is very often in that column. In 99.999% other situation query optimizer use FKbetween master and detail table. One of my partner told me last month that they have some problem with Java app on SA11. And what did he say ? "One query in their app works fast,fast,fast for a seconds and then slow.... slow... for a hours". And what was suggestion ? "ADD ON clause in select command if you have JOIN". And ? Yes, now work fast, fast, fast and still working fast. |
#8
| |||
| |||
|
|
The use of implied key joins (JOIN without an ON condition) and fast-slow-fast query plans are unrelated. Using JOIN without an ON condition is processed very early - the query is rewritten to include the ON condition defined by the foreign key relationships before the query goes through subsequent optimization. If you have fast vs. slow query plans for the same query, post the graphical plans (with statistics) of each instance and I'll take a look at them. Glenn Bofcilo wrote: On Nov 18, 10:28 am, Volker Barth <No_VBarth (AT) Spam_GLOBAL-FINANZ (DOT) de wrote: Bofcilo wrote: I detected this in ASA7 version and still happened in SA11 version. So my instruction to our programmers is : DO NOT USE ONLY JOIN in select command, USE JOIN .. ON ... !!!!! IMHO, each JOIN that is not a NATURAL JOIN, a KEY JOIN or a CROSS JOIN *must* use an ON clause to specify the join condition. Otherwise the JOIN keywords seems quite useless. It seems that SA accepts the mere "JOIN" when there are FKs between the tables (and so might use a KEY JOIN silently). Call it a bug or a feature... When there are no FKs between the table, an error is raised.. (Tested on ASA 8.0.3.5574 and 11.0.1.2331). I frankly use KEY JOINs quite often as the syntax is handy, but have never had performance problems with those joins. HTH Volker Ok, i have to add more about this. First, I know for KEY JOIN and existing FKs between tables. I don't write about bug. I confirm that we detect problem in query optimizer in very specific situation. For many months one query on customer location work fine, fast. And then start slow execution. We tested that query in iSql and there found different query plan between fast and slow execution. Again, SAME query without any changes did work fast. First solution was drop statitistic (something like that i forgot). After that query work fast, and after some days again slow. Then we try (it is not needed) with rewriting query. ON clause was added in JOIN between master and detail tables and for many, many years works fine. This is happened in ASA7. Ok, it was first time, but believe me or not, there was in other app and situations. Something has been repeat. It is happened only IF master table has foreign key on column and one value is very often in that column. In 99.999% other situation query optimizer use FKbetween master and detail table. One of my partner told me last month that they have some problem with Java app on SA11. And what did he say ? "One query in their app works fast,fast,fast for a seconds and then slow.... slow... for a hours". And what was suggestion ? "ADD ON clause in select command if you have JOIN". And ? Yes, now work fast, fast, fast and still working fast. -- Glenn Paulley Director, Engineering (Query Processing) Sybase iAnywhere Blog:http://iablog.sybase.com/paulley EBF's and Patches:http://downloads.sybase.com * choose SQL Anywhere Studio >> change 'time frame' to all To Submit Bug Reports:http://case-express.sybase.com SQL Anywhere Studio Supported Platforms and Support Statushttp://my.sybase.com/detail?id=1002288 Whitepapers, TechDocs, and bug fixes are all available through the Sybase iAnywhere pages athttp://www.sybase.com/products/databasemanagement/sqlanywhere/technic... |
#9
| |||
| |||
|
|
On Nov 18, 1:03 pm, "Glenn Paulley [Sybase iAnywhere]" paul... (AT) ianywhere (DOT) com> wrote: The use of implied key joins (JOIN without an ON condition) and fast-slow-fast query plans are unrelated. Using JOIN without an ON condition is processed very early - the query is rewritten to include the ON condition defined by the foreign key relationships before the query goes through subsequent optimization. If you have fast vs. slow query plans for the same query, post the graphical plans (with statistics) of each instance and I'll take a look at them. Glenn Bofcilo wrote: On Nov 18, 10:28 am, Volker Barth <No_VBarth (AT) Spam_GLOBAL-FINANZ (DOT) de wrote: Bofcilo wrote: I detected this in ASA7 version and still happened in SA11 version. So my instruction to our programmers is : DO NOT USE ONLY JOIN in select command, USE JOIN .. ON ... !!!!! IMHO, each JOIN that is not a NATURAL JOIN, a KEY JOIN or a CROSS JOIN *must* use an ON clause to specify the join condition. Otherwise the JOIN keywords seems quite useless. It seems that SA accepts the mere "JOIN" when there are FKs between the tables (and so might use a KEY JOIN silently). Call it a bug or a feature... When there are no FKs between the table, an error is raised. (Tested on ASA 8.0.3.5574 and 11.0.1.2331). I frankly use KEY JOINs quite often as the syntax is handy, but have never had performance problems with those joins. HTH Volker Ok, i have to add more about this. First, I know for KEY JOIN and existing FKs between tables. I don't write about bug. I confirm that we detect problem in query optimizer in very specific situation. For many months one query on customer location work fine, fast. And then start slow execution. We tested that query in iSql and there found different query plan between fast and slow execution. Again, SAME query without any changes did work fast. First solution was drop statitistic (something like that i forgot). After that query work fast, and after some days again slow. Then we try (it is not needed) with rewriting query. ON clause was added in JOIN between master and detail tables and for many, many years works fine. This is happened in ASA7. Ok, it was first time, but believe me or not, there was in other app and situations. Something has been repeat. It is happened only IF master table has foreign key on column and one value is very often in that column. In 99.999% other situation query optimizer use FKbetween master and detail table. One of my partner told me last month that they have some problem with Java app on SA11. And what did he say ? "One query in their app works fast,fast,fast for a seconds and then slow.... slow... for a hours". And what was suggestion ? "ADD ON clause in select command if you have JOIN". And ? Yes, now work fast, fast, fast and still working fast. -- Glenn Paulley Director, Engineering (Query Processing) Sybase iAnywhere Blog:http://iablog.sybase.com/paulley EBF's and Patches:http://downloads.sybase.com choose SQL Anywhere Studio >> change 'time frame' to all To Submit Bug Reports:http://case-express.sybase.com SQL Anywhere Studio Supported Platforms and Support Statushttp://my.sybase.com/detail?id=1002288 Whitepapers, TechDocs, and bug fixes are all available through the Sybase iAnywhere pages athttp://www.sybase.com/products/databasemanagement/sqlanywhere/technic... Yes i have fast vs slow query plans for the same query. Only if i add ON clause then query optimizer is forced to use FK between master- detail tables not FK on master table. I did click on "replay to author" with question how to send to you jpegs ? If it's wrong way to ask you please send email to sprintrz (AT) gmail (DOT) com with instructions. Thx. |
![]() |
| Thread Tools | |
| Display Modes | |
| |