fetchall

Why is the same SQLite query being 30 times slower when fetching only twice as many results?

我只是一个虾纸丫 提交于 2019-12-02 18:52:14
I have been working on speeding up a query I'm using for about a week now and asked several questions about it here ( How can I speed up fetching the results after running an sqlite query? , Is it normal that sqlite.fetchall() is so slow? , How to use min() and max() in an efficient way? ). With the very useful help from the answers given there I managed to get the time down to the sqlite query taking 100.95 seconds and fetchall taking: 1485.43 . This was still not enough, so after trying out some different indexes I managed to get the query time down to 0.08 seconds for one sample and the

About mysql cursor and iterator

蓝咒 提交于 2019-11-30 03:03:53
Imagine I have a mysql cursor and data read. The amount of data might be very big that I want to deal with one line each time. An easy and straight forward way might be like this: while True: row = cursor.fetchone() if not row: break ..... but this doesn't look good, so I wonder whether this way works as imagined: for row in iter(cursor.fetchall()) the thing I want to know is: if I use the iter(cursor.fetchall()) way, does it fetch all the data first or it just fetch one row at a time? Any idea is appreciated. thx The MySQLdb cursor class implements the iterator protocol , so you can simply do

How can I speed up fetching the results after running an sqlite query?

牧云@^-^@ 提交于 2019-11-29 11:47:27
As an answer on my question: Is it normal that sqlite.fetchall() is so slow? it seems that fetch-all and fetch-one can be incredibly slow for sqlite. As I mentioned there, I have the following query: time0 = time.time() self.cursor.execute("SELECT spectrum_id, feature_table_id "+ "FROM spectrum AS s "+ "INNER JOIN feature AS f "+ "ON f.msrun_msrun_id = s.msrun_msrun_id "+ "INNER JOIN (SELECT feature_feature_table_id, min(rt) AS rtMin, max(rt) AS rtMax, min(mz) AS mzMin, max(mz) as mzMax "+ "FROM convexhull GROUP BY feature_feature_table_id) AS t "+ "ON t.feature_feature_table_id = f.feature

About mysql cursor and iterator

泪湿孤枕 提交于 2019-11-29 00:43:28
问题 Imagine I have a mysql cursor and data read. The amount of data might be very big that I want to deal with one line each time. An easy and straight forward way might be like this: while True: row = cursor.fetchone() if not row: break ..... but this doesn't look good, so I wonder whether this way works as imagined: for row in iter(cursor.fetchall()) the thing I want to know is: if I use the iter(cursor.fetchall()) way, does it fetch all the data first or it just fetch one row at a time? Any

python postgres can I fetchall() 1 million rows?

只愿长相守 提交于 2019-11-28 21:26:51
I am using psycopg2 module in python to read from postgres database, I need to some operation on all rows in a column, that has more than 1 million rows. I would like to know would cur.fetchall() fail or cause my server to go down? (since my RAM might not be that big to hold all that data) q="SELECT names from myTable;" cur.execute(q) rows=cur.fetchall() for row in rows: doSomething(row) what is the smarter way to do this? fetchall() fetches up to the arraysize limit, so to prevent a massive hit on your database you can either fetch rows in manageable batches, or simply step through the cursor

PDO looping throug and printing fetchAll

走远了吗. 提交于 2019-11-28 06:36:25
I'm having trouble getting my data from fetchAll to print selectively. In normal mysql I do it this way: $rs = mysql_query($sql); while ($row = mysql_fetch_array($rs)){ $id = $row['id']; $n = $row['n']; $k = $row['k']; } In PDO, I'm having trouble. I bound the params, then I'm saving the fetched data into $rs like above, with the purpose of looping through it the same way.. $sth->execute(); $rs = $query->fetchAll(); Now comes the trouble part. What do I do PDO-wise to get something matching the while loop above?! I know I can use print_r() or dump_var, but that's not what I want. I need to do

How can I speed up fetching the results after running an sqlite query?

半腔热情 提交于 2019-11-28 05:09:11
问题 As an answer on my question: Is it normal that sqlite.fetchall() is so slow? it seems that fetch-all and fetch-one can be incredibly slow for sqlite. As I mentioned there, I have the following query: time0 = time.time() self.cursor.execute("SELECT spectrum_id, feature_table_id "+ "FROM spectrum AS s "+ "INNER JOIN feature AS f "+ "ON f.msrun_msrun_id = s.msrun_msrun_id "+ "INNER JOIN (SELECT feature_feature_table_id, min(rt) AS rtMin, max(rt) AS rtMax, min(mz) AS mzMin, max(mz) as mzMax "+

python postgres can I fetchall() 1 million rows?

风格不统一 提交于 2019-11-27 12:59:49
问题 I am using psycopg2 module in python to read from postgres database, I need to some operation on all rows in a column, that has more than 1 million rows. I would like to know would cur.fetchall() fail or cause my server to go down? (since my RAM might not be that big to hold all that data) q="SELECT names from myTable;" cur.execute(q) rows=cur.fetchall() for row in rows: doSomething(row) what is the smarter way to do this? 回答1: fetchall() fetches up to the arraysize limit, so to prevent a

Fatal error: Call to undefined method mysqli_result::fetch_all()

喜欢而已 提交于 2019-11-27 09:13:07
I have problems with PHP in Ubuntu 10.04. When I try use mysqli_result::fetch_all this error appears: Call to undefined method mysqli_result::fetch_all() However, it works in Windows XP. The Code: $result = $this->dbh->query('SELECT [...] '); return $result->fetch_all(MYSQLI_ASSOC); I don't want to use fetch_assoc with a loop because I send the result to another layer for processing. I'm using PHP 5.4.4. and with php -m | grep mysql the mysqlnd module it doesn't appear. How can I install it? Could that be the problem? Ibrahim Azhar Armar mysqli_result::fetch_all() requires MySQL Native Driver

php PDO fetchAll() - while not working, foreach works

与世无争的帅哥 提交于 2019-11-27 07:51:25
问题 I would like to know if i'm doing fine OR fetchAll() doesn't work with WHILE. here is an exemple $db=new PDO("mysql:host=" .$dbhost. "; dbname=" . $dbname, $dbuser, $dbpass); $page=$db->prepare("SELECT * FROM page"); $page->execute(); foreach ($page->fetchAll(PDO::FETCH_ASSOC) as $row) { //echo a row //is working } however, i if try looping with a while while ($row=$page->fetchAll(PDO::FETCH_ASSOC)){ //echo a row //Show empty } i tryed to use only fetch(), it was working, my question: why