Re: Slooooow query question
Posted in 1995
Topics: General Discussion
Todd M. Saylor (tsaylor@ecst.csuchico.edu) wrote: : This isn't realy a *slow* question, but a question about slow queries. :) : Anyway, I'm trying to do a query such as the following: : SELECT x FROM y ORDER BY x : In this example, 'x' is a "primary key" with a unique index. As you would : expect, this returns rows immediately. However, when I make the following : change, there is a long pause as Informix examines the entire table: : SELECT DISTINCT x FROM y ORDER BY x : I would expect the query to simply follow the unique index and start returning : rows immediately, but apparently it shifts into "distinct" mode and checks : all rows in the selection set for uniqueness. Additionally, I'm hoping to : be able to do a similar query on a table whose index is NOT unique. It would : seem to me that Informix is *able* to return such a query quickly (i.e. without : examining the entire table before returning any rows), but whether it actually : does so is another matter. : I've tried this query under Informix OnLine 5.0 and 6.0, with the same results. : Setting the optimization level or updating statistics high does not seem to : change anything. : Is there any way to speed up a DISTINCT query? Am I just out of luck? : Any help would be greatly appreciated. : -- : ------------------------------------------------------------------------------- : Todd Saylor | Bi-Tech Software, Inc. : "No matter where you go, there you are" | (916) 891-5281 : ----------- Opinions expressed are subject to change without notice ----------- -- +----------------------------------------------------------------------------+ | OSS / XCOM / A&M / TV | | ===================== | | Pierre NICOLET Email : P.Nicolet@frec.bull.fr | | Bull SA Phone : +33 76 39 78 57 or 229 78 57 | | 1, rue de Provence Telex : 980 648 F | | B.P. 208 Fax : +33 76 39 78 62 | | 38432 Echirolles CEDEX Room : FREC-B1/038 | | France PC : FREC-B1/054 | +----------------------------------------------------------------------------+