[Question] Optimize multiple reads on same DataFrame
- Lingua principale
- Rust
- Stelle
- 9.3k
- Fork
- 2.4k
- Merge medio
- 3g 11h
- PR unite (30g)
- 360
Descrizione
Hey,
I have a scenario where I have to run the same filter expression but with different values on the same RecordBatch
For example
```
let c2: Vec = ....
let provider = datafusion::datasource::MemTable::try_new(c2[0].schema(), vec![c2])
.map_err(|e| {
log::error!("Error MemTable {}", e);
e
})
.unwrap();
let ctx = SessionContext::new();
ctx.register_table("t", provider ).unwrap();
let df = ctx.table("t").unwrap();
let expr: Expr = get_expression(id, from_time, to_time)
let df = df.filter(expr).unwrap();
let res = df.collect().await.unwrap();
ctx.deregister_table("t").unwrap();
```
It is pretty fast, a few ms on a 80MiB in-memory array with filtering on 2 columns.
I might run 1000 queries on the same MemTable and was wondering if there is anything that could be optimized:
- pre computing an execution plan on the MemTable if it's cost effective
- Is SessionContext thread safe and shareable between multiple threads and be optimized across executions?
- Somehow create an index (not sure if an index is created by one of the calls or supported at all) if it's cost effective
Thanks!
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia leggendo gli entry point MemTable, SessionContext, DataFrame::filter e DataFrame::collect menzionati nella domanda. Determina se letture filtrate ripetute possono riutilizzare il lavoro di pianificazione o esecuzione, se SessionContext supporta l’uso concorrente richiesto e se l’indicizzazione è supportata; il lavoro sarà completato con una risposta documentata o una proposta di miglioramento circoscritta.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- rust
- Ambito
- databases
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 20/100