🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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=' ')
  1. A.SCAN SCAN
  2. B.SEARCH SEARCH
  3. C.SEARCH SCAN
  4. 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 →