ewaters / altsql-shell

An easily extensible DBI shell, perfect for a drop-in replacement to mysql-client
http://ewaters.github.com/altsql-shell
123 stars 19 forks source link

Avoid long running table calculations #2

Open ewaters opened 12 years ago

ewaters commented 12 years ago

Upon selecting a very large and wide data set, there is a lot of processing to be done to compute optimal UnicodeBox tables. Take this example I just ran into:

mysqlc> select count(*) from faq_questions;
┏━━━━━━━━━━┓
┃ count(*) ┃
┡━━━━━━━━━━┩
│ 12551    │
└──────────┘
1 rows in set (0.01 sec)

mysqlc> select max(length(answer)) from faq_questions;
┏━━━━━━━━━━━━━━━━━━━━━┓
┃ max(length(answer)) ┃
┡━━━━━━━━━━━━━━━━━━━━━┩
│ 1172                │
└─────────────────────┘
1 rows in set (0.02 sec)

A select * from this table hung for half a minute before I had to kill it; most likely took lots of time trying to draw the huge table.

romuloab commented 12 years ago

You could draw the table for what is actually shown on screen, and then resize as needed (when scrolled). This way you only have to fetch n rows, where n is the number of rows that fit on screen or an arbitrary number like 200