Hi all, thanks for the suggestions so far.  However, this definitely seems
to be down to the size of the table more than anything else.

Beyond a certain size MIN(), MAX() and TOP 1 all stop working even though
SYS(3054) still reports full optimization!  Any ideas if this max working
table size can be changed by some memory setting or other?

Example:

SELECT TOP 1 OrdNo FROM OrdersNoOnly WHERE OrdNo > cLastOrdNo ;
        AND Left(OrdNo,1) = cDept ORDER BY OrdNo
* takes 50 seconds

SELECT OrdNo FROM Orders INTO TABLE OrdersNoOnly
INDEX ON OrdNo TAG OrdNo
INDEX ON LEFT(OrdNo,1) TAG Dept

SELECT TOP 1 OrdNo FROM OrdersNoOnly WHERE OrdNo > cLastOrdNo ;
        AND Left(OrdNo,1) = cDept ORDER BY OrdNo
* takes 0.7 seconds

Nick


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
> Of NickC
> Sent: 07 September 2008 18:18
> To: 'ProFox Email List'
> Subject: RE: SQL > not optimised
> 
> Slight progress but no idea why!
> 
> 
> Three ways that don't work (too slow):
> 
> SELECT MIN(OrdNo) FROM Orders WHERE OrdNo > cLastPONum
> 
> SELECT TOP 1 OrdNo FROM Orders WHERE OrdNo > cLastPONum ORDER BY OrdNo ASC
> 
> SELECT * FROM Orders WHERE OrdNo IN ;
>       (SELECT TOP 1 OrdNo FROM Orders WHERE OrdNo > cLastPONum ;
>       ORDER BY OrdNo ASC)
> 
> 
> And one way that does work:
> SELECT OrdNo FROM Orders WHERE OrdNo > cLastPONum ORDER BY OrdNo INTO
> CURSOR
> Temp1
> cOrdNo = Temp1.OrdNo
> 
> However put a MIN, MAX or TOP 1 on and it goes excruciatingly slow again.
> 
> Nick
> 
> 
> 
> 
[excessive quoting removed by server]

_______________________________________________
Post Messages to: ProFox@leafe.com
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: 
http://leafe.com/archives/byMID/profox/!&!AAAAAAAAAAAYAAAAAAAAAOO2KhH5xw1Oq9ETMzh8UaqijQAAEAAAAEY+dm+3/FxMuh/[EMAIL
 PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to