Sobes.tech
Junior — Middle

Have you created indexed structures to speed up database queries?

sobes.tech AI

Answer from AI

Yes, creating indexed structures is a common way to speed up queries in databases. Indexes allow for quick retrieval of records without scanning the entire table.

For example, in Python with SQLite, you can create an index like this:

import sqlite3
conn = sqlite3.connect('example.db')
cursor = conn.cursor()
cursor.execute('CREATE INDEX IF NOT EXISTS idx_user_email ON users(email)')
conn.commit()

Here, the index on the email field in the users table will speed up searches for users by email. Indexes are especially useful for fields that are frequently filtered or sorted.