Hi,

As was explained in http://issues.apache.org/scarab/issues/id/TRQS318, LargeSelect has a very poor performance for databases with no native limit/offset. I lookead at the code myself and also am of the opinion that using LargesSelect makes no sense if the db does not support native limit/offset.

Therefore I am inclined to follow the proposed solution and throw an exception in the constructor of LargeSelect if the chosen DB does not support native limit and offset. The code would look loke:

    private void init(Criteria criteria, int pageSize, int
                      memoryLimitPages)
            throws IllegalArgumentException
    {
        ...

        {
            String dbName = criteria.getDbName();
            if (dbName == null)
            {
                dbName = Torque.getDefaultDB();
            }
            if (dbName == null)
            {
                throw new RuntimeException(
                        "Torque is not initialized yet");
            }
            DB db;
            try
            {
                db = Torque.getDB(dbName);
            }
            catch (TorqueException e)
            {
                throw new RuntimeException(
                        "cannot retieve Database for DB name " + dbName);
            }
            if (db.getLimitStyle() == DB.LIMIT_STYLE_NONE)
            {
                throw new IllegalArgumentException(
                        "criteria must have a db which supports "
                        + "native Limit and Offset");
            }
        }

        ...

Are there any objections ? Is everybody ok with throwing a RuntimeException, or would it be better to add the TorqueException to the throws clause, possibly breaking people's code because TorqueException is not caught ?

I would also guess that the problems with databases which do not support native limit/offset have lead to the exclusion of the LargeSelectTest from the runtimetest. Does anybody object to include the LargeSelectTest and print an error but not execute the test if the database dose not support native limit/offset ? Sample code would be

public class LargeSelectTest extends BaseRuntimeTestCase
{
    ....

    public void testLargeSelect() throws TorqueException
    {
        if (Torque.getDB(Torque.getDefaultDB()).getLimitStyle()
                == DB.LIMIT_STYLE_NONE)
        {
            log.error("LargeSelect is known not to work for databases "
                    + "which do not support native limit/offset");
            return;
        }

    ....

If one adds this, the LargeSelectTest also runs for hsqldb which does not support native limit/offset.


     Thomas

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to