sql-execution-plan

disable explain in Rails 3.2

南笙酒味 提交于 2019-12-20 10:33:26
问题 Is it possible to disable the new the explain functionality in Rails 3.2 globally via configuration? I'm using activerecord-sqlserver-adapter 3.2.1 and there appear to be some bugs with the explain (show plan) portion of the gem. 回答1: To cite from http://weblog.rubyonrails.org/2011/12/6/what-s-new-in-edge-rails-explain/ New applications get config.active_record.auto_explain_threshold_in_seconds = 0.5 in config/environments/development.rb . Active Record monitors queries and if they take more

What is the difference between Seq Scan and Bitmap heap scan in postgres?

有些话、适合烂在心里 提交于 2019-12-20 08:38:54
问题 In output of explain command I found two terms 'Seq Scan' and 'Bitmap heap Scan'. Can somebody tell me what is the difference between these two types of scan? (I am using PostgreSql) 回答1: http://www.postgresql.org/docs/8.2/static/using-explain.html Basically, a sequential scan is going to the actual rows, and start reading from row 1, and continue until the query is satisfied (this may not be the entire table, e.g., in the case of limit) Bitmap heap scan means that PostgreSQL has found a

What is query execution doing to this query in SQL Server 2005?

丶灬走出姿态 提交于 2019-12-20 07:26:47
问题 Today I found this query in our code that pulls up a list of errors from our database: SELECT * FROM ( SELECT Substring(title, 9, Patindex('%)%', title) - 9) AS SERVICE, * FROM core.LOG WHERE logtypeid = 1 AND title LIKE 'Error: (%' AND lastmodified > '2010-06-21T00:00:00' AND lastmodified < '2010-06-22T00:00:00' ) serviceerrors WHERE SERVICE = 'CheckHelpDeskEmail' It fails with the following error: Invalid length parameter passed to the SUBSTRING function. If I remove the WHERE clause on the

EXPLAIN and COUNT returning two different values

試著忘記壹切 提交于 2019-12-20 02:14:03
问题 i am doing: explain select * from calibration; it says 52133456345632 rows when i do: select count(*) from calibration; i am getting 52134563456961 can someone explain whats going on here? 回答1: Table statistics (used by EXPLAIN) are based on system-cached values that may not be accurate. http://dev.mysql.com/doc/refman/5.1/en/using-explain.html says: For InnoDB tables, this number is an estimate, and may not always be exact. So the 'count()' version of the query will be accurate, as it will

Is there a way to force MySQL execution order?

試著忘記壹切 提交于 2019-12-19 05:04:15
问题 I know I can change the way MySQL executes a query by using the FORCE INDEX (abc) keyword. But is there a way to change the execution order? My query looks like this: SELECT c.* FROM table1 a INNER JOIN table2 b ON a.id = b.table1_id INNER JOIN table3 c ON b.itemid = c.itemid WHERE a.itemtype = 1 AND a.busy = 1 AND b.something = 0 AND b.acolumn = 2 AND c.itemid = 123456 I have a key for every relation/constraint that I use. If I run explain on this statement I see that mysql starts querying c

Searching for table/index scans

孤人 提交于 2019-12-19 03:21:29
问题 Does anyone have a query which searches through SQL2005/2008's plan cache identifying queries or stored procedures which have table/index scans within their execution plans? 回答1: Pinal Dave actually did a post about this and with a bit of alteration on his original article (barely any alteration required!) you can get the right answer. If he's got an account, credit him :) http://blog.sqlauthority.com/2009/03/17/sql-server-practical-sql-server-xml-part-one-query-plan-cache-and-cost-of

Easy way to run “explain” on query sets in django

吃可爱长大的小学妹 提交于 2019-12-18 11:03:06
问题 It seems like it should be easy to run "explain" directly off of a queryset in Django, but I don't see anything obvious for how to do it, and "explain" is a difficult thing to search for in the docs. 回答1: Well, there seems to be nothing out there except a toolbar so I wrote my own mixin to give me an explain() method on my querysets: from django.db import connections from django.db.models.query import QuerySet class QuerySetExplainMixin: def explain(self): cursor = connections[self.db].cursor

How does SQL server work out the estimated number of rows?

て烟熏妆下的殇ゞ 提交于 2019-12-18 08:31:43
问题 I'm trying to debug a fairly complex stored procedure that joins across many tabls (10-11). I'm seeing that for a part of the tree the estimated number of rows drasticly differs from the actual number of rows - at its worst SQL server estimates that 1 row will be returned, when in actuality 55,000 rows are returned! I'm trying to work out why this is - all of my statistics are up-to-date, and I've updated statistics with a FULLSCAN on several tables. I'm not using any user defined functions

How can I analyse a Sqlite query execution?

こ雲淡風輕ζ 提交于 2019-12-17 21:50:10
问题 I have a Sqlite database which I want to check the indexes are correct. MS SQL Analyser is great at breaking down the query execution and utilised indexes. Is there a similar tool for Sqlite? 回答1: I know of no pretty graphical tools, but all of the information you seek is available from the EXPLAIN keyword. Consider this database: sqlite> create table users (name, email); sqlite> create index user_names on users (name); A query predicated on email will not use an index: sqlite> explain select

How do I obtain a Query Execution Plan?

不想你离开。 提交于 2019-12-16 18:14:30
问题 In Microsoft SQL Server how can I get a query execution plan for a query / stored procedure? 回答1: There are a number of methods of obtaining an execution plan, which one to use will depend on your circumstances. Usually you can use SQL Server Management Studio to get a plan, however if for some reason you can't run your query in SQL Server Management Studio then you might find it helpful to be able to obtain a plan via SQL Server Profiler or by inspecting the plan cache. Method 1 - Using SQL