← Quiz: Query Processing and Optimization: all 10 questions
Quiz: Query Processing and Optimization · Question 8 of 10
What does this print? (code)
What does this print?
import sqlite3
db = sqlite3.connect(':memory:')
db.execute('CREATE TABLE t (a INTEGER, b TEXT)')
db.execute('CREATE INDEX ia ON t(a)')
for sql in ["SELECT * FROM t WHERE a = 5", "SELECT * FROM t WHERE b = 'x'"]:
detail = db.execute('EXPLAIN QUERY PLAN ' + sql).fetchone()[3]
print(detail.split()[0], end=' ')
- A.SCAN SCAN
- B.SEARCH SEARCH
- C.SEARCH SCAN
- D.SCAN SEARCH
Answer & explanation
Correct answer: SEARCH SCAN
Column a has an index, so it is searched; b has none, so the table is scanned.
Can you get the rest right without peeking?
Take the timed Quiz: Query Processing and Optimization quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →