From ec6e970bbcae70b2844a8260a1fb10a0bc0234f9 Mon Sep 17 00:00:00 2001 From: Colin Dellow Date: Sun, 24 Jun 2018 15:20:06 -0400 Subject: [PATCH] Fix `order by rowid` to apply w/o clause Fixes #12, first screen of datasette is fast now --- parquet/parquet.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/parquet/parquet.cc b/parquet/parquet.cc index 908f2f4..e768590 100644 --- a/parquet/parquet.cc +++ b/parquet/parquet.cc @@ -650,6 +650,11 @@ static int parquetBestIndex( printf("%llu xBestIndex: nConstraint=%d, nOrderBy=%d\n", millisecondsSinceEpoch, pIdxInfo->nConstraint, pIdxInfo->nOrderBy); debugConstraints(pIdxInfo, table, 0, NULL); #endif + // We traverse in rowid ascending order, so if they're asking for it to be ordered like that, + // we can tell SQLite that it's guaranteed. This speeds up some DB viewer utilities that + // use rowids for pagination. + if(pIdxInfo->nOrderBy == 1 && pIdxInfo->aOrderBy[0].iColumn == -1 && pIdxInfo->aOrderBy[0].desc == 0) + pIdxInfo->orderByConsumed = 1; if(pIdxInfo->nConstraint == 0) { pIdxInfo->estimatedCost = 1000000000000; @@ -659,11 +664,6 @@ static int parquetBestIndex( pIdxInfo->idxNum = 1; int j = 0; - // We traverse in rowid ascending order, so if they're asking for it to be ordered like that, - // we can tell SQLite that it's guaranteed. This speeds up some DB viewer utilities that - // use rowids for pagination. - if(pIdxInfo->nOrderBy == 1 && pIdxInfo->aOrderBy[0].iColumn == -1 && pIdxInfo->aOrderBy[0].desc == 0) - pIdxInfo->orderByConsumed = 1; for(int i = 0; i < pIdxInfo->nConstraint; i++) { if(pIdxInfo->aConstraint[i].usable) { j++;