Lesson 4 Flashcards
LIMIT & TOP (6 cards)
In the real world, tables can have ____ of rows which can take a long time to process… and be very expensive!
_______________________________________________________________
- Many of the new cloud platforms (like Snowflake and other data warehouses) ____
In the real world, tables can have millions of rows which can take a long time to process… and be very expensive!
_______________________________________________________________
- Many of the new cloud platforms (like Snowflake and other data warehouses) bill based on usage (either on the amount of data pulled or computation time)
____ when possible for better optimization – especially when you’re just exploring your data!
Limit rows and columns when possible for better optimization – especially when you’re just exploring your data!
Why (and when) would you want to reduce the rows of your output?
(More than 1 answer)
- Faster
- Likely less expensive
_________________________________________________
If you’re brand new to a table, can help you get a sense of:
- What does this table look like?
- What kind of data (data types) does it have?
- What columns does it have?
- Helps you get a sneak preview of the table / get an overall feel for your data
How can we reduce the rows of our output and get a sneak peek of our data?
______________________________________________
For example, how can you pull all the columns (but only 100 rows) from the orders
table?
Can add LIMIT
to the end of any query and follow with how many rows you want in the output:
SELECT * FROM orders LIMIT 100
Caution:
You can / can NOT make assumptions on results using a limited output
You can NOT make assumptions on results using a limited output
- This is just a little sample of our data – we can’t make assumptions without performing additional analytics on the entire column/table
If your SQL dialect/platform doesn’t support LIMIT
(but most new ones should), try using ___ instead
TOP
- Can always Google/ChatGPT/Gemini etc. to figure out syntax issues