From the course: SQL: Data Reporting and Analysis
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Make your queries faster - SQL Tutorial
From the course: SQL: Data Reporting and Analysis
Make your queries faster
- [Instructor] If we click on the payment table, you can see that there are 16,000 odd results. And this query took 0.0009 seconds. Now we're going to limit our query to 25 rows, and do that by limit 25 and click go. Now you can see that the query took a little bit less time, 0.007 seconds to run. But when we're dealing with millions of rows, this sort of thing can make a substantial difference. The limit keyword works in MySQL and PostgreSQL, but unfortunately the keywords differ in different versions. So for Microsoft, the keyword is top, and you use it like this. You'd say select top 25, field name, whatever that field name may be from the payment table. And obviously you don't need that bit. And for Oracle, it would be select, I'll show you. Star from the table. And then it's used as a filter where ROWNUM is less than or equal to 25. And ROWNUM isn't a field, it's Oracle's own way of counting the rows in the database.…
Contents
-
-
-
-
-
-
(Locked)
Make your queries faster1m 47s
-
(Locked)
Understand SQL indexes and keys7m 16s
-
(Locked)
EDIT: Visualize your database7m 58s
-
(Locked)
Merge data across tables with JOIN5m 2s
-
(Locked)
Understand SQL JOINS4m 16s
-
(Locked)
Combine rows with SQL UNION4m 49s
-
(Locked)
Merge data across tables with IN2m 11s
-
(Locked)
Select from a selection with subqueries2m 56s
-
(Locked)
Challenge: Join tables1m 4s
-
(Locked)
Solution: Join tables4m 37s
-
(Locked)
-
-