Skip to content

Commit b41321f

Browse files
nipunn1313Convex, Inc.
authored andcommitted
Do db-info in creation time order (#30927)
GitOrigin-RevId: f5fe6c63eab0d19851bc06dcc74a839e0ddb38c5
1 parent 0d743ab commit b41321f

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

crates/database/src/database.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,10 +484,24 @@ impl<RT: Runtime> DatabaseSnapshot<RT> {
484484
runtime: &RT,
485485
tablet_id: TabletId,
486486
) -> anyhow::Result<LatestDocumentStream<'a>> {
487-
let table_by_id = self.index_registry().must_get_by_id(tablet_id)?.id();
488487
let table_iterator = self.table_iterator(runtime.clone());
489-
let stream = table_iterator.stream_documents_in_table(tablet_id, table_by_id, None);
490-
Ok(stream.map_ok(|(document, ts)| (ts, document)).boxed())
488+
let by_creation_time = self
489+
.index_registry()
490+
.get_enabled(&TabletIndexName::by_creation_time(tablet_id));
491+
let stream = if let Some(by_creation_time) = by_creation_time {
492+
let stream = table_iterator.stream_documents_in_table_by_index(
493+
tablet_id,
494+
by_creation_time.id(),
495+
IndexedFields::creation_time(),
496+
None,
497+
);
498+
stream.map_ok(|(_, ts, document)| (ts, document)).boxed()
499+
} else {
500+
let table_by_id = self.index_registry().must_get_by_id(tablet_id)?.id();
501+
let stream = table_iterator.stream_documents_in_table(tablet_id, table_by_id, None);
502+
stream.map_ok(|(document, ts)| (ts, document)).boxed()
503+
};
504+
Ok(stream)
491505
}
492506

493507
/// Fetch _tables.by_id and _index.by_id for bootstrapping.

0 commit comments

Comments
 (0)