"Development" <[EMAIL PROTECTED]> wrote:
> 
> This table gets filled in a random order with the SortID being generated =
> on load. The Select query then changes slightly to enforce this order:
> 
> SELECT
>       T1.TheID,
>       T1.Column1,
>       T1.Column6,
>       T2.Column2,
>       T2.Column3,
>       T2.Column6,
>       T3.Column8,
>       T4.Column2,
>       S.SortID
> FROM
>     Table1 as T1 inner join Table2 as T2 on T1.TheID = T2.TheID
>     inner join Table3 as T3 on T1.TheID = T3.TheID
>     inner join Table4 as T4 on T1.TheID = T4.TheID
>     inner join SortOrder as S on T1.TheId = S.TheID
> where
>      S.SortID >= 100001 and
>      S.SortID <= 150000
> order by
>      S.SortID asc
> 
> This query performs very badly.

What does EXPLAIN QUERY PLAN say?

I'm guessing it might go faster if you (1) run ANALYZE first or
(2) record the ORDER BY clause to say:  "S.SortID +asc".
--
D. Richard Hipp   <[EMAIL PROTECTED]>

Reply via email to