Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > how to control ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 3560 of 3799
Post > Topic >>

how to control the execution plan ?

by "Sabin Coanda" <sabin.coanda@[EMAIL PROTECTED] > Jul 7, 2008 at 12:14 PM

Hi there,

I try to execute the following statement:

SELECT *
FROM (
    SELECT "MY_FUNCTION_A"(bp."COL_A", NULL::boolean) AS ALIAS_A
    FROM "TABLE_A" bp
        JOIN "TABLE_B" pn ON bp."COL_B" = pn."PK_ID"
        JOIN "TABLE_C" vbo ON bp."COL_C" = vbo."PK_ID"
    WHERE pn."Editor"::text ~~ 'Some%'::text AND bp."COL_A" IS NOT NULL
AND 
bp."COL_A"::text <> ''::text
) x
WHERE (x.ALIAS_A::text ) IS NULL;

The problem is the excution plan first make Seq Scan on "TABLE_A", with 
Filter: (("COL_A" IS NOT NULL) AND (("COL_A")::text <> ''::text) AND 
(("MY_FUNCTION_A"("COL_A", NULL::boolean))::text IS NULL))". This way, 
MY_FUNCTION_A crashes for some unsup****ted data provided by  "COL_A".

I'd like to get an execution plan which is filtering first the desired
rows, 
and just after that compute te column value "MY_FUNCTION_A"(bp."COL_A", 
NULL::boolean).

I made different combinations, including a subquery like:

SELECT *
FROM (
    SELECT "MY_FUNCTION_A"(y."COL_A", NULL::boolean) AS ALIAS_A
    FROM (
        SELECT bp."COL_A"
        FROM "TABLE_A" bp
            JOIN "TABLE_B" pn ON bp."COL_B" = pn."PK_ID"
            JOIN "TABLE_C" vbo ON bp."COL_C" = vbo."PK_ID"
        WHERE pn."COL_E"::text ~~ 'Some%'::text AND bp."COL_A" IS NOT NULL

AND bp."COL_A"::text <> ''::text
    ) y
) x
WHERE (x.ALIAS_A::text ) IS NULL;

but postgres analyze is too 'smart' and optimize it as in the previous
case, 
with the same Seq Scan on "TABLE_A", and with the same filter.

I thought to change the function MY_FUNCTION_A, to sup****t any argument 
data, but the even that another performance problem will be rised when the

function will be computed for any row in join, even those that can be 
removed by other filter.

Do you have a solution please ?

TIA
Sabin
 




 3 Posts in Topic:
how to control the execution plan ?
"Sabin Coanda"   2008-07-07 12:14:24 
Re: how to control the execution plan ?
scott.marlowe@[EMAIL PROT  2008-07-07 15:14:00 
Re: how to control the execution plan ?
"Sabin Coanda"   2008-07-08 19:37:41 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Dec 2 21:27:46 CST 2008.