Closed
Description
I have a table with 7 columns and ~ 10 million of rows. I rewrote my python code that selects the entire table to rust and noticed that rust version is much slower.
Rust code
use postgres::{Client, NoTls};
use fallible_iterator::FallibleIterator;
fn main() {
let mut client = Client::connect("host=/var/run/postgresql user=user", NoTls).unwrap();
let mut it = client.query_iter("SELECT * FROM my_table", &[]).unwrap();
while let Some(_row) = it.next().unwrap() {
}
}
time:
204.36s user 184.91s system 238% cpu 2:43.22 total
Python code
#!/usr/bin/env python3
import psycopg2
def main():
with psycopg2.connect("user='user'") as con, con.cursor() as cur:
cur = con.cursor()
cur.execute('SELECT * FROM my_table;')
for row in cur:
pass
if __name__ == '__main__':
main()
time:
14.60s user 2.48s system 43% cpu 39.215 total
Metadata
Metadata
Assignees
Labels
No labels