Subject | Specifying a plan |
---|---|
Author | David K. Trudgett |
Post date | 2001-12-07T03:19:53Z |
Hi all,
I have a couple of queries (see below) that I would like to speed up.
I could do it using two queries, but that would necessitate some other
design changes to the application (not a big deal, but I'd prefer not
to have to touch it).
The two queries do similar things, but I eschewed the INNER JOIN
syntax on the second, hoping it might make a difference. It didn't.
I thought it would be easier to specify a plan, but I haven't done that
before. What I would like to tell the engine, if it's possible, is,
the case of the second query, for example: "go get the row from table
HSUB that matches on the unique index, then join with table MAST on
MASTNUMB = HSUBNUMB". What it's doing at the moment (stupid, stupid
;-)) is joining two huge tables with over 200,000 rows each, and then
finding the one matching row out of it.
SELECT
*
FROM
MAST INNER JOIN ENTF
ON MASTNUMB = ENTFNUMB
WHERE
ENTFENTITLEMENTNO = :NO
SELECT
*
FROM
HSUB, MAST
WHERE
HSUBHIN = :NO AND
MASTNUMB = HSUBNUMB
These queries take 7 seconds to return a result. Needs to be under 0.5
seconds :-)
Thanks.
David Trudgett
I have a couple of queries (see below) that I would like to speed up.
I could do it using two queries, but that would necessitate some other
design changes to the application (not a big deal, but I'd prefer not
to have to touch it).
The two queries do similar things, but I eschewed the INNER JOIN
syntax on the second, hoping it might make a difference. It didn't.
I thought it would be easier to specify a plan, but I haven't done that
before. What I would like to tell the engine, if it's possible, is,
the case of the second query, for example: "go get the row from table
HSUB that matches on the unique index, then join with table MAST on
MASTNUMB = HSUBNUMB". What it's doing at the moment (stupid, stupid
;-)) is joining two huge tables with over 200,000 rows each, and then
finding the one matching row out of it.
SELECT
*
FROM
MAST INNER JOIN ENTF
ON MASTNUMB = ENTFNUMB
WHERE
ENTFENTITLEMENTNO = :NO
SELECT
*
FROM
HSUB, MAST
WHERE
HSUBHIN = :NO AND
MASTNUMB = HSUBNUMB
These queries take 7 seconds to return a result. Needs to be under 0.5
seconds :-)
Thanks.
David Trudgett