Re: add LIMIT statement? (reduce size of resultset)

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Wed Sep 01 2004 - 09:23:06 EDT

  • Next message: Michele Cuozzo: "auto_pk_support"

    Agree, doing this at the database level should be a good optimization.
    As different DBs use a different syntax for the row limit, this is a
    fairly big change, so we should postpone this till 1.2 (please open a
    feature request!)

    On the other hand I want to try java.sql.Statement.setMaxRows(int).
    Cayenne currently doesn't rely on this API, and I hope at least some
    drivers implement "maxRows" support to smartly optimize the query. I
    don't have too much hope here though, looks like we still will need to
    generate correct SELECT.

    Andrus

    On Sep 1, 2004, at 6:28 AM, Twan Kogels wrote:
    > Hello,
    >
    > Is it possible to add a "LIMIT" statement to the end of a query which
    > SelectQuery executes? (like: select * from users where age < 25 LIMIT
    > 50 )
    >
    > I'm currently testing my application and have a table with 20.000
    > records. I'm doing a query on this table and i sometimes get over
    > 10.000 records. That's a bit too large. So i tryed setFetchLimit(50),
    > but after reading the documentation setFetchLimit doesn't limit the
    > size of the resultset, it only limits how many rows in the resultset
    > cayenne will convert. This means i'm still stuck with a resultset of
    > 10.000 rows and cayenne is only reading 50 of them :-)
    >
    > The difference between a query which results in a resultset of 10.000
    > or a query which results in a resultset of 50 is about 2,5 seconds.
    >
    > Cheers,
    > Twan Kogels



    This archive was generated by hypermail 2.0.0 : Wed Sep 01 2004 - 09:23:11 EDT