Questions tagged [explain]

Explain is a SQL command that shows the execution plan of a query.

Explain is an useful command used in various Database servers(like Oracle, MySQL, PostgreSQL, etc). It shows the execution plan of a query.

Oracle:

EXPLAIN PLAN FOR SELECT …

PostgreSQL, MySQL:

EXPLAIN SELECT …

MSSQL doesn't support explain, but uses

"SET SHOWPLAN_TEXT ON".

instead.

599 questions
2
votes
1 answer

Explain sorting in Solr with multiple sort clauses

Imagine there's a Solr request with multiple sort clauses (not on score obviously). Is there a way to figure out, for every found document, which of those clauses resulted in a tie with neighbours and which were actually used for sorting? I'm…
alamar
  • 18,729
  • 4
  • 64
  • 97
2
votes
0 answers

What is the estimate elapsed time for a query given its explained cost

If I use postgres's EXPLAIN command, there's a top-level "cost". Assuming that the explain is accurate (ie despite the cost being in reality quite unreliable and/or inconsistent), what is the very approximate conversion from cost to minutes/seconds…
Bohemian
  • 412,405
  • 93
  • 575
  • 722
2
votes
1 answer

Mysql - Using temporary; Using filesort

I have two tables like this CREATE TABLE `vendors` ( vid int(10) unsigned NOT NULL AUTO_INCREMENT, updated timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (vid), key(updated) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE…
mesibo
  • 3,970
  • 6
  • 25
  • 43
2
votes
0 answers

MySQL 5.7: 'EXPLAIN' takes very long time to execute with a long 'IN' list

While issuing SELECT COUNT(*) queries to our MySQL DB, we always perform also an EXPLAIN query and log its results for debugging purposes. Some of our queries include an IN clause with a long list of values (may be 100K+, against an indexed column).…
urim
  • 591
  • 4
  • 13
2
votes
0 answers

using TKPROF and EXPLAIN with a lowercase username

I am attempting to tune our oracle database that has been running a little slowly lately. I have generated a SQL trace file, and can run the basic TKPROF from the command prompt, and generate the appropriate output file. tkprof.exe source.trc…
mbw
  • 366
  • 3
  • 12
2
votes
1 answer

What is the difference? Can you please explain the syntax?

I'm new in React-Native and I faced with two different (for me) instructions in tutorials. Could you please explain me the difference between them? 1) var React = require('react-native'); vs import React, { AppRegistry, Component, StyleSheet, …
Drupal Noob
  • 153
  • 6
2
votes
1 answer

Is there a way to show MYsql explain plan like Oracle as a tree

Sample query: create table t1(c1 int primary key); MySQL mysql> explain select c1 from t1; +----+-------------+-------+------------+-------+---------------+---------+---------+------+------+----------+-------------+ | id | select_type | table |…
Dylan Su
  • 5,975
  • 1
  • 16
  • 25
2
votes
0 answers

Why does this explain indicate an index was not used?

Given the following query: var exp = db.messages.explain('executionStats') exp.find( { 'headers.Date' : { '$gt' : new Date(2001,3,1) } }, { 'headers.From' : 1, '_id' : 0 } ).sort( { 'headers.From' : 1 } ) That produces the following output: { …
David says Reinstate Monica
  • 19,209
  • 22
  • 79
  • 122
2
votes
2 answers

What is the proper way to order by a condition that depends on the current time?

I need to order records and put "hot" (promoted) records on top. A record is "hot" if its hot_expires_at column is not null and in the future. Currently I have this straightforward solution: ORDER BY IF( hot_expires_at IS NOT NULL AND…
Leonid Shevtsov
  • 14,024
  • 9
  • 51
  • 82
2
votes
1 answer

Mysql Left join not using foreign key

I have a problem executing a simple LEFT JOIN. When I run EXPLAIN SELECT * FROM Feature f LEFT JOIN feature_translations t ON f.id = t.object_id I got the following…
2
votes
1 answer

Query Optimization - Type: ALL, Key = NULL

Similar questions have been asked, and I've reworked this query with every suggestion, but can't figure out the issue. When submit the following query to EXPLAIN EXTENDED I receive both 'Type' = 'ref' and a key was found for each table (although I…
user3242558
  • 105
  • 1
  • 9
2
votes
3 answers

What is the difference between !($x == ' ' OR $y == ' ') and $x != ' ' OR $y != ' '

What is the difference of between the following examples? FIRST EXAMPLE if($x != '' or $y != '' or $z!=''or $c!=''){ echo "

YOUR INPUT:

"; echo $x.'
'.$y.'
'.$z.'
'.$c.'
'; } SECOND EXAMPLE if(!($x == '' or $y == '' or…
2
votes
1 answer

Optimize MySQL indexes to query in less than a second

The query time for a very simple min-max no-join no-nesting SQL is taking more than 2 seconds. THE TABLE STRUCTURE::: > DESCRIBE tbl; +-------------+--------------+------+-----+---------+----------------+ | Field | Type | Null | Key |…
Rakib
  • 12,376
  • 16
  • 77
  • 113
2
votes
1 answer

Could someone tell me what this code does bit for bit?

I can understand largely what this bit of code means. I need to use it and I also want to understand what it means precisely. Could someone explain it to me piece by piece? Currently I read it as "The variable 'hash' includes the key 'flowers' and…
Erik Aasland
  • 167
  • 1
  • 11
2
votes
2 answers

Why is an index not used on a LIKE query with wildcards?

Although the Title column was added as index by using the following query: ALTER TABLE Recipe ADD INDEX Title_idx (Title) MySQL doesn't use that index for this query: SELECT * FROM Recipe WHERE Title LIKE '%cake%'; I used the EXPLAIN keyword and…
Fabio
  • 1,272
  • 3
  • 21
  • 41