Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 11-20-2009, 07:16 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by cbk1994 View Post
more efficient
Not necessarily. If that field is not indexed, then it will have to do a sort on the returned rows by moving the result to a temporary table and sorting them there with an internal algorithm that may not be sufficient for your data size, which can be very, very, very expensive when you have a lot of rows. If the field is indexed, then it will be faster because the b-tree index keeps it in order during the insertion/deletion, and it is only matter of reading things sequentially at that point.

Note that the optimizer can only make use of an index on the ORDER BY if it is a composite index covering all the WHERE conditions and ORDER BY conditions.

e.x.,
PHP Code:
SELECT FROM tbl WHERE a 'value' ORDER BY bc
requires the following index: (a,b,c).

e.x.,
PHP Code:
SELECT FROM tbl WHERE a 'value' AND 'value' ORDER BY c
requires the following index: (a,b,c).



The overhead of talking to SQLite and the overhead within the engine also certainly need to be taken into account when doing something small, where it often makes things faster to just manipulate the data in GS2.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 01:17 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.