diff options
author | Jamey Hicks <jamey.hicks@nokia.com> | 2012-06-08 11:45:28 -0400 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-08 18:40:13 +0200 |
commit | db5a44785e398fe3fee884316d39dca0f1be35ad (patch) | |
tree | f3b113b52b1d20a24693b9ff66be71f0ce01695a | |
parent | 876a0cfa56cdc9ed175b482a8f45018bf1538b86 (diff) |
Speed up [?_uuid="undefined"] queries
This query is causing jsondb to read the whole object table even
though it will never match.
If the min or max key value provided to JsonDbUuidQuery::seekToStart
is not a valid UUID, then return false. This will cause the query to
return 0 objects without reading any of the object table.
Change-Id: Ie337cd66cb6d789066cd07847cc8c00ed86d5dce
Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
-rw-r--r-- | src/partition/jsondbindexquery.cpp | 4 | ||||
-rw-r--r-- | src/partition/jsondbobjectkey.h | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/partition/jsondbindexquery.cpp b/src/partition/jsondbindexquery.cpp index 0a1fc23..67ca57a 100644 --- a/src/partition/jsondbindexquery.cpp +++ b/src/partition/jsondbindexquery.cpp @@ -327,6 +327,8 @@ bool JsonDbUuidQuery::seekToStart(QJsonValue &fieldValue) if (mQuery.isAscending()) { if (!mMin.isUndefined()) { ObjectKey objectKey(mMin.toString()); + if (!objectKey.isValid()) + return false; ok = mCursor->seekRange(objectKey.toByteArray()); } else { ok = mCursor->first(); @@ -334,6 +336,8 @@ bool JsonDbUuidQuery::seekToStart(QJsonValue &fieldValue) } else { if (!mMax.isUndefined()) { ObjectKey objectKey(mMax.toString()); + if (objectKey.isValid()) + return false; ok = mCursor->seekRange(objectKey.toByteArray()); } else { ok = mCursor->last(); diff --git a/src/partition/jsondbobjectkey.h b/src/partition/jsondbobjectkey.h index ca51295..5d03a82 100644 --- a/src/partition/jsondbobjectkey.h +++ b/src/partition/jsondbobjectkey.h @@ -67,6 +67,8 @@ public: { return key.toRfc4122(); } + inline bool isValid() const + { return !key.isNull(); } inline bool operator==(const ObjectKey &rhs) const { return key == rhs.key; } |