0
0
PostgreSQLquery~10 mins

Why performance tuning matters in PostgreSQL - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to select all columns from the employees table.

PostgreSQL
SELECT [1] FROM employees;
Drag options to blanks, or click blank then click option'
Aeverything
BALL
C*
Dcolumns
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ALL' instead of '*'
Using 'columns' which is not valid SQL
2fill in blank
medium

Complete the code to filter employees with salary greater than 50000.

PostgreSQL
SELECT * FROM employees WHERE salary [1] 50000;
Drag options to blanks, or click blank then click option'
A>
B<
C=
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' which means less than
Using '=' which means equal
3fill in blank
hard

Fix the error in the query to count employees in each department.

PostgreSQL
SELECT department, COUNT([1]) FROM employees GROUP BY department;
Drag options to blanks, or click blank then click option'
Asalary
B*
Cdepartment
Demployee_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using COUNT(department) which counts non-null departments
Using COUNT(employee_id) which may miss nulls
4fill in blank
hard

Fill both blanks to create an index on the salary column to improve query speed.

PostgreSQL
CREATE INDEX idx_salary ON employees USING [1]([2]);
Drag options to blanks, or click blank then click option'
ABTREE
BHASH
Csalary
Ddepartment
Attempts:
3 left
💡 Hint
Common Mistakes
Using HASH which is less common and limited
Indexing the wrong column like department
5fill in blank
hard

Fill all three blanks to write a query that selects employee names and orders them by salary descending.

PostgreSQL
SELECT [1], salary FROM employees ORDER BY [2] [3];
Drag options to blanks, or click blank then click option'
Aname
Bsalary
CDESC
DASC
Attempts:
3 left
💡 Hint
Common Mistakes
Ordering by name instead of salary
Using ASC instead of DESC for descending order