I have a large query joining eleven tables together with a resulset of 15000 records. By default (all records) the query has 6 predicates in the where clause. It will cost the databaseserver about ten seconds to cough up the recordset. When I add another predicate in the where clause the number of records decrease. But the execution time of the query gets longer strongly depending on how many results are returned, for example if 125 rows are returned it takes 3 seconds longer. The more records are returned the worse it gets.... Sometimes over 2 minutes.... It looks like it uses another query plan, which in this case is obviously a bad plan.
How can I influence this behaviour? I tried:
FROM ***.pub.polis P WITH (INDEX (nr_tussenp)) LEFT JOIN .....
The index nr_tussenp is the best index of the main table (polis) in all cases (in my opinion) so it should always use this one.
I tried to view the query plan by executing:
con.Execute("SET PRO_SERVER LOG ON WITH (QUERY_PLAN)")
Then execute my query.
And then opening a recordset like:
Set rsRec = con.Execute("SELECT SUBSTR(description,1,78) FROM pub.""_SQL_QPLAN"" WHERE _ptype > 0")
Do Until rsRec.eof
Response.Write rsRec(0) & "<br>"
rsRec.MoveNext
Loop
rsRec.Close
Set rsRec = Nothing
But the query returns an error I've never seen before so that's not very useful either.
[DataDirect][ODBC Progress OpenEdge Wire Protocol driver][OPENEDGE]Encountered internal error in SQL ENGINE at 166 in /vobs_sql/sql/src/public/rss\rss_env.hxx. Contact Progress Technical Support
Anyone who can help me tuning this query?
How can I influence this behaviour? I tried:
FROM ***.pub.polis P WITH (INDEX (nr_tussenp)) LEFT JOIN .....
The index nr_tussenp is the best index of the main table (polis) in all cases (in my opinion) so it should always use this one.
I tried to view the query plan by executing:
con.Execute("SET PRO_SERVER LOG ON WITH (QUERY_PLAN)")
Then execute my query.
And then opening a recordset like:
Set rsRec = con.Execute("SELECT SUBSTR(description,1,78) FROM pub.""_SQL_QPLAN"" WHERE _ptype > 0")
Do Until rsRec.eof
Response.Write rsRec(0) & "<br>"
rsRec.MoveNext
Loop
rsRec.Close
Set rsRec = Nothing
But the query returns an error I've never seen before so that's not very useful either.
[DataDirect][ODBC Progress OpenEdge Wire Protocol driver][OPENEDGE]Encountered internal error in SQL ENGINE at 166 in /vobs_sql/sql/src/public/rss\rss_env.hxx. Contact Progress Technical Support
Anyone who can help me tuning this query?