Re: query optimization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

If I am not mistaken,
the second part of the union contains all rows that are in the first part of
the union. just remove the first part.

Also....


What is the table sizes of the tables?
How many records are expected to come back from the union sub query?
How many records are expected to come back from the main query
What is the current execution plan?

Jack




2008/9/26 YVES SUCAET <yves.sucaet@xxxxxxx>

> How could I rewrite the following query so it runs faster:
>
> select distinct location from blockunit where blockid in (
>  select bu.blockid from blockunit bu inner join interactionparts ip on
> (bu.blockid = ip.part)
>  where ip.blockid in
>
>
> (110936,110937,111641,111642,113140,113141,114925,114926,121161,121162,124087,
>  124088,124562,124563,133358,133359,133409,133410,135304,135305,136096)
>  union
>  select bu.blockid from blockunit bu
>  where bu.blockid in
>
>
> (110936,110937,111641,111642,113140,113141,114925,114926,121161,121162,124087,
>  124088,124562,124563,133358,133359,133409,133410,135304,135305,136096)
> )
>
> Thanks in advance,
>
> Yves
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
J.A. van Zanen

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux