altsql-shell icon indicating copy to clipboard operation
altsql-shell copied to clipboard

Avoid long running table calculations

Open ewaters opened this issue 12 years ago • 1 comments

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.

  • If a select would generate a huge table, ask the user: "The resulting table would be #### wide and #### tall. Continue? (y/N)"
  • Alternatively, show an abbreviated output: "The resulting table would have been #### by ####; showing only #### rows with wrapping output"

ewaters avatar May 08 '12 16:05 ewaters

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

romuloab avatar Jul 13 '12 13:07 romuloab