Module: ArJdbc::HSQLDB::ExplainSupport

Included in:
ArJdbc::HSQLDB
Defined in:
lib/arjdbc/hsqldb/explain_support.rb

Instance Method Summary collapse

Instance Method Details

#explain(arel, binds = []) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/arjdbc/hsqldb/explain_support.rb', line 6

def explain(arel, binds = [])
  sql = "EXPLAIN PLAN FOR #{to_sql(arel, binds)}"
  raw_result = exec_query_raw(sql, "EXPLAIN", binds)
  # HSQLDB's SqlTool just prints it as it comes :
  #
  #  sql> EXPLAIN PLAN FOR SELECT * FROM entries JOIN users on ... ;
  #
  # isDistinctSelect=[false]
  # isGrouped=[false]
  # isAggregated=[false]
  # columns=[  COLUMN: PUBLIC.ENTRIES.ID
  #  not nullable  COLUMN: PUBLIC.ENTRIES.TITLE
  #  nullable  COLUMN: PUBLIC.ENTRIES.UPDATED_ON
  #  nullable  COLUMN: PUBLIC.ENTRIES.CONTENT
  #  nullable  COLUMN: PUBLIC.ENTRIES.RATING
  #  nullable  COLUMN: PUBLIC.ENTRIES.USER_ID
  #  nullable  COLUMN: PUBLIC.USERS.ID
  #  not nullable  COLUMN: PUBLIC.USERS.LOGIN
  #  nullable
  # ]
  # ...
  # PARAMETERS=[]
  # SUBQUERIES[]
  #
  raw_result.map!(&:values)
  raw_result.join("\n")
end

#supports_explain?Boolean

Returns:

  • (Boolean)


4
# File 'lib/arjdbc/hsqldb/explain_support.rb', line 4

def supports_explain?; true; end