add remove split language chart show hidden hide
db<>fiddle
donate feedback about
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
category_1_operations.date_-1
[Function: insert]
VACUUM
[
  {
    _id: 2816,
    operations: [ { date: ISODate('2026-09-25T21:31:01.209Z'), amount: 807 } ]
  }
]
{
  stage: 'LIMIT',
  startupCost: 0,
  totalCost: 0.21,
  estimatedTotalKeysExamined: 1,
  inputStage: {
    stage: 'PROJECT',
    startupCost: 0,
    totalCost: 0.21,
    estimatedTotalKeysExamined: 1,
    inputStage: {
      stage: 'FETCH',
      ns: 'test.accounts',
      startupCost: 0,
      totalCost: 32.12,
      estimatedTotalKeysExamined: 159,
      inputStage: {
        stage: 'IXSCAN',
        ns: 'test.accounts',
        indexName: 'category_1_operations.date_-1',
        direction: 'Forward',
        indexUsage: {
          indexKeyString: '{"category": 1,"operations.date": -1}',
          isMultiKey: true,
          bounds: [
            '["category": [1, 1], "operations.date": DESC(MinKey, MaxKey)]'
          ]
        },
        startupCost: 0,
        totalCost: 32.12,
        hasOrderBy: true,
        indexFilterSet: [ { category: { '$eq': 1 } } ],
        estimatedTotalKeysExamined: 159
      }
    }
  }
}
QUERY PLAN
Subquery Scan on agg_stage_3 (actual time=0.107..0.108 rows=1.00 loops=1)
  Output: documentdb_api_internal.bson_dollar_project(agg_stage_3.document, 'BSONHEX31000000106f7065726174696f6e732e616d6f756e740001000000106f7065726174696f6e732e64617465000100000000'::documentdb_core.bson, 'BSONHEX12000000096e6f7700aca17adaa001000000'::documentdb_core.bson)
  Buffers: shared hit=4
  -> Limit (actual time=0.097..0.098 rows=1.00 loops=1)
        Output: collection.document, (documentdb_api_catalog.bson_orderby(collection.document, 'BSONHEX1a000000106f7065726174696f6e732e6461746500ffffffff00'::documentdb_core.bson))
        Buffers: shared hit=4
        -> Custom Scan (DocumentDBApiExplainQueryScan) (actual time=0.096..0.096 rows=1.00 loops=1)
              Output: collection.document, documentdb_api_catalog.bson_orderby(collection.document, 'BSONHEX1a000000106f7065726174696f6e732e6461746500ffffffff00'::documentdb_core.bson)
              namespaceName: test.accounts
              indexName: category_1_operations.date_-1
              indexKey: {"category": 1,"operations.date": -1}
              isMultiKey: true
              indexBounds: ["category": [1, 1], "operations.date": DESC(MinKey, MaxKey)]
              innerScanLoops: 1 loops
              scanType: ordered
              scanKeyDetails: key 1: [(isInequality: true, estimatedEntryCount: 31)]
              _id_: (startup cost=0.275, total cost=39.445, selectivity=1, correlation=0.750, estimated index pages loaded=100.00%, estimated total index entries=956, boundary selectivity=1, num boundaries=0, estimated data pages loaded=0.00%)
              Buffers: shared hit=4
              -> Index Scan using "category_1_operations.date_-1" on documentdb_data.documents_2 collection (actual time=0.053..0.053 rows=1.00 loops=1)
                    Output: collection.document
                    Index Cond: (collection.document OPERATOR(documentdb_api_catalog.@=) 'BSONHEX130000001063617465676f7279000100000000'::documentdb_core.bson)
                    Order By: (collection.document OPERATOR(documentdb_api_catalog.|-<>) 'BSONHEX1a000000106f7065726174696f6e732e6461746500ffffffff00'::documentdb_core.bson)
                    Index Searches: 0
                    Buffers: shared hit=4
Planning:
  Buffers: shared hit=518
Planning Time: 1.612 ms
Execution Time: 0.197 ms
EXPLAIN
SET
SELECT 956
SELECT 1000
CREATE INDEX
CREATE INDEX
VACUUM
account_id category date amount
2816 1 2026-09-25 21:31:01.209+00 807
SELECT 1
QUERY PLAN
Sort (actual time=0.325..0.326 rows=1.00 loops=1)
  Output: a.account_id, a.category, o.date, o.amount
  Sort Key: o.date
  Sort Method: quicksort Memory: 25kB
  Buffers: shared hit=18
  -> Nested Loop (actual time=0.322..0.324 rows=1.00 loops=1)
        Output: a.account_id, a.category, o.date, o.amount
        Buffers: shared hit=18
        -> Nested Loop (actual time=0.318..0.319 rows=1.00 loops=1)
              Output: a_1.account_id, a.account_id, a.category
              Buffers: shared hit=15
              -> Limit (actual time=0.312..0.313 rows=1.00 loops=1)
                    Output: a_1.account_id, o_1.date
                    Buffers: shared hit=12
                    -> Sort (actual time=0.312..0.312 rows=1.00 loops=1)
                          Output: a_1.account_id, o_1.date
                          Sort Key: o_1.date DESC
                          Sort Method: top-N heapsort Memory: 25kB
                          Buffers: shared hit=12
                          -> Hash Join (actual time=0.108..0.270 rows=342.00 loops=1)
                                Output: a_1.account_id, o_1.date
                                Hash Cond: (o_1.account_id = a_1.account_id)
                                Buffers: shared hit=12
                                -> Seq Scan on documentdb_api.account_operations o_1 (actual time=0.005..0.055 rows=1000.00 loops=1)
                                      Output: o_1.account_id, o_1.date, o_1.amount
                                      Buffers: shared hit=7
                                -> Hash (actual time=0.100..0.100 rows=326.00 loops=1)
                                      Output: a_1.account_id
                                      Buckets: 1024 Batches: 1 Memory Usage: 20kB
                                      Buffers: shared hit=5
                                      -> Seq Scan on documentdb_api.accounts a_1 (actual time=0.003..0.064 rows=326.00 loops=1)
                                            Output: a_1.account_id
                                            Filter: (a_1.category = 1)
                                            Rows Removed by Filter: 630
                                            Buffers: shared hit=5
              -> Index Only Scan using accounts_account_id_category_idx on documentdb_api.accounts a (actual time=0.005..0.005 rows=1.00 loops=1)
                    Output: a.account_id, a.category
                    Index Cond: (a.account_id = a_1.account_id)
                    Heap Fetches: 0
                    Index Searches: 1
                    Buffers: shared hit=3
        -> Index Scan using account_operations_account_id_date_idx on documentdb_api.account_operations o (actual time=0.003..0.003 rows=1.00 loops=1)
              Output: o.account_id, o.date, o.amount
              Index Cond: (o.account_id = a.account_id)
              Index Searches: 1
              Buffers: shared hit=3
Planning:
  Buffers: shared hit=36
Planning Time: 0.362 ms
Execution Time: 0.348 ms
EXPLAIN