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 - [EMAIL PROTECTED] ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org