0
0
PostgreSQLquery~10 mins

Why indexing strategy 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 create an index on the column 'username' in the 'users' table.

PostgreSQL
CREATE INDEX idx_username ON users([1]);
Drag options to blanks, or click blank then click option'
Ausername
Buser_id
Cemail
Dpassword
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a column that is not used in queries often.
Trying to create an index on a non-existent column.
2fill in blank
medium

Complete the query to find users with the email 'example@example.com' using the index.

PostgreSQL
SELECT * FROM users WHERE [1] = 'example@example.com';
Drag options to blanks, or click blank then click option'
Ausername
Bemail
Cuser_id
Dcreated_at
Attempts:
3 left
💡 Hint
Common Mistakes
Using a column that is not indexed.
Using a column unrelated to the filter condition.
3fill in blank
hard

Fix the error in the index creation statement by completing the blank.

PostgreSQL
CREATE INDEX idx_created [1] users (created_at);
Drag options to blanks, or click blank then click option'
AON
BINDEX
CUNIQUE
DTABLE
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the 'ON' keyword.
Using 'TABLE' instead of 'ON'.
4fill in blank
hard

Fill both blanks to create a unique index on the 'email' column in the 'customers' table.

PostgreSQL
CREATE [1] INDEX idx_email_unique [2] customers (email);
Drag options to blanks, or click blank then click option'
AUNIQUE
BTEMPORARY
CON
DTABLE
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'TABLE' instead of 'ON'.
Forgetting 'UNIQUE' for unique indexes.
5fill in blank
hard

Fill the blanks to drop an index named 'idx_username' from the 'users' table.

PostgreSQL
DROP [1] IF EXISTS [2];
Drag options to blanks, or click blank then click option'
AINDEX
BTABLE
Cidx_username
Dusers
Attempts:
3 left
💡 Hint
Common Mistakes
Using DROP TABLE instead of DROP INDEX.
Omitting the index name.