-
Notifications
You must be signed in to change notification settings - Fork 14.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SQL Lab] Improve result table rendering performance #7690
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome, I think it will greatly improve with the wide tables we've been previewing. I have just a comment on the font, we should have a designer chime in, since the new font is much harder to read IMHO.
@@ -43,6 +43,11 @@ | |||
border-right: 1px solid #ccc; | |||
align-self: center; | |||
padding: 12px; | |||
font-family: monospace; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we could have a more specific font here first (falling back to monospace
if not available), so the results look better? At least in the screenshot you posted the monospaced font seems harder to read than before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested with 'Roboto Mono', monospace
and it looks somewhat better IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'd need to include roboto mono
with the website then, not sure if it's worth adding a dependency there on a font. Let's see what someone more design minded thinks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessarily, it would fall back to monospace
if Roboto Mono
is not installed.
GitHub uses SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace;
, eg.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Different fonts would have different character widths, which would make this even harder to implement though..
return getTextDimension({ text, style: { font } }).width; | ||
} | ||
|
||
const CHARACTER_WIDTH = 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@etr2460, can you test your modifications with Unicode data? You can try a query like this:
SELECT 'アイウ1234', 'QRS12', '台北1234';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern is that strings with the same number of characters may have different widths when rendering in monospace. For example, these 3 strings all have 3 characters:
'アイウ',
'123',
'QRS'
Note that they're rendered with different widths, since some characters are half-width and others are double.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
>>> a = ['123', 'アイウ', 'QRS']
>>> [len(i) for i in a]
[3, 3, 3]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see your point here. It is possible to get the columns to overflow with enough double wide characters, but in that case you can still hover over the column to see the full results, or copy/paste to the same effect.
@etr2460 I'm doing some tests trying to optimize |
That should definitely help performance too! I think separate of the performance question, we should consider if monospace is the right direction to go for the query results. For some types of data, I think it's actually easier to read in monospace, but it probably depends on people's preference |
Design change: @elibrumbaugh do you wanna take a look? Context is above |
@etr2460 Thanks for the tag. I find the monospace easier to read and it sounds like a big win for performance. My biggest concern is how "spaced" out the letters are now. In design we call this tracking or more recently letter-spacing. Check out this bit about legibility.
Keep me posted! |
I apologize Erik, I made a mistake. Monospace of course is a fixed width. I wonder if it's worth the extra space because of the advantage of spacing out compressed syntax per the link I shared in this comment. |
@elibrumbaugh spacing out JSON is definitely a perk for using a monospace font here. I'll try to find some folks who use sql lab on a daily basis for feedback! |
Personally I prefer the old style, but I've learned to trust designers in cases like this. If @elibrumbaugh says it's better I'm happy to go with it. :) |
Thanks Beto 🙏We'll def confirm with users first! |
Side note outside the scope of this PR: I thought before that it could be good to limit/collapse wide columns to say 100 chars by default and allow users to expand it. Maybe a right caret in the column header that widens the column to its full extend? For |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@betodealmeida let me know what sorts of perf improvements you get by changing the measurement component. if that fixes it enough, then we can make the table monospaced with better looking fonts, otherwise this is probably fine to merge as is. I spoke with some other users of SQL Lab and they all were ok with the change
@@ -43,6 +43,11 @@ | |||
border-right: 1px solid #ccc; | |||
align-self: center; | |||
padding: 12px; | |||
font-family: monospace; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Different fonts would have different character widths, which would make this even harder to implement though..
return getTextDimension({ text, style: { font } }).width; | ||
} | ||
|
||
const CHARACTER_WIDTH = 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see your point here. It is possible to get the columns to overflow with enough double wide characters, but in that case you can still hover over the column to see the full results, or copy/paste to the same effect.
Superseded by #8011 |
CATEGORY
Choose one
SUMMARY
When rendering the FilterableTable component we were rendering and measuring the width of every cell to determine the width of each column. For tables with many columns or columns with large amounts of content, this would hang the page for seconds at a time:
This fix changes the font for the FilterableTable to monospaced so that we can calculate the max width of a column without rendering the each cell. This resulted in a 665x improvement in perf for the function (>3 s down to 4.8 ms in some nasty edge cases)
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before:
After:
TEST PLAN
Ensure the column widths still fit all the content. Pass CI
ADDITIONAL INFORMATION
REVIEWERS
@graceguo-supercat @soboko @mistercrunch @john-bodley