Databases

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • Performance of two queries, why such big difference ?

    0 answers - 1978 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    >Yes, but it completes the first query in 1ms somehow, so where is the

    >difference ?

    From your original email

    >WHERE channel = ? AND time >= ?
    >RDER BY time ASC "


    >WHERE channel IN (-2,?) AND time >= ?
    >RDER BY time ASC "

    the WHERE clause is different, that is why you are getting the
    different processing times. I think you are actually trying to find out
    why 1 query is 200x faster than the other.
    There could be a few reasons why they are different - possible
    reason is that you have a large number of records where the channel
    value is set to "-2". Dan has also given a suggestion to try a different
    approach to get the same answer to the second query.
    Without giving more information, there is a limit to how much help
    members of this list can give. You may wish to post the results of the
    following queries which may help identify your problem.
    SELECT count(*)
    FRM files
    WHERE channel = ? AND time >= ?
    RDER BY time ASC "
    LIMIT ?
    SELECT count(*)
    FRM files
    WHERE channel IN (-2,?) AND time >= ?
    RDER BY time ASC "
    LIMIT ?
    Also tell us the values used for the "?"
    As I mentioned earlier, try using the EXPLAIN keyword which describes
    how the internals of SQLite are working. If you have difficulty in
    understanding the output of EXPLAIN, post the results to this mailing
    list and I'm sure someone (with greater knowledge of this command than
    myself) will respond.
    Nick
    This email and any attachments are confidential to the intended
    recipient and may also be privileged. If you are not the intended
    recipient please delete it from your system and notify the sender.
    You should not copy it or use it for any purpose nor disclose or
    distribute its contents to any other person.

Re: Performance of two queries, why such big difference ?


max 4000 letters.
Your nickname that display:
In order to stop the spam: 8 + 7 =
QUESTION ON "Databases"

EMSDN.COM