RE : Large querie with several EXISTS which will be often runned - Mailing list pgsql-performance

From Bruno BAGUETTE
Subject RE : Large querie with several EXISTS which will be often runned
Date
Msg-id !~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAATBuXKOMvlkWzD3KJN6FWLMKAAAAQAAAAMZDMAFkAG0K6t6raV9fLGwEAAAAA@baguette.net
Whole thread Raw
In response to Re: Large querie with several EXISTS which will be often runned  (Josh Berkus <josh@agliodbs.com>)
Responses Re: Large querie with several EXISTS which will be often runned  (Shridhar Daithankar <shridhar_daithankar@persistent.co.in>)
List pgsql-performance
Hello Josh,

> > I will have to manage more or less 10.000 products with
> more or less
> > 2-3 options by products and more or less 40 options-groups.
> >
> > Do you think that this query will be hard for PostgreSQL (currently
> > 7.2.1 but I will migrate to 7.3.2 when going in production
> > environment) ? How can I improve that query to be faster ?
>
> Collapse the inner EXISTS into a straight join in the outer
> EXISTS.  Since you
> are merely checking for existence, there is no reason for the
> subquery
> nesting.

Do you mean this query ?

SELECT
products_options_groups.pk_prdoptgrp_id,products_options_groups.prdoptgr
p_name
FROM products_options_groups
WHERE EXISTS
(
    SELECT *
    FROM products_options_classification
    INNER JOIN products_options ON products_options.pk_prdopt_id =
products_options_classification.fk_prdopt_id
    WHERE products_options_classification =
products_options_groups.pk_prdoptgrp_id
    AND products_options.fk_prd_id = [A PRODUCT ID WRITTEN HERE BY
MY APP]
)
ORDER BY products_options_groups.prdoptgrp_name;


An other question, do you think that my tables are OK or is there some
things I could change in order to have as much performance as possible
(without de-normalize it because I want to avoid redundancy in my
tables).

Thanks very much for your tips ! :-)

---------------------------------------
Bruno BAGUETTE - pgsql-ml@baguette.net


pgsql-performance by date:

Previous
From: "scott.marlowe"
Date:
Subject: Re: Memory question
Next
From: Shridhar Daithankar
Date:
Subject: Re: Large querie with several EXISTS which will be often runned