full-table-scan

Why NonClustered index scan faster than Clustered Index scan?

自作多情 提交于 2019-12-14 01:42:22
问题 As I know, heap tables are tables without clustered index and has no physical order. I have a heap table "scan" with 120k rows and I am using this select: SELECT id FROM scan If I create a non-clustered index for the column "id", I get 223 physical reads . If I remove the non-clustered index and alter the table to make "id" my primary key (and so my clustered index), I get 515 physical reads . If the clustered index table is something like this picture: Why Clustered Index Scans workw like

MySql - Self Join - Full Table Scan (Cannot Scan Index)

烂漫一生 提交于 2019-12-13 08:01:54
问题 I have the following self-join query: SELECT A.id FROM mytbl AS A LEFT JOIN mytbl AS B ON (A.lft BETWEEN B.lft AND B.rgt) The query is quite slow, and after looking at the execution plan the cause appears to be a full table scan in the JOIN. The table has only 500 rows, and suspecting this to be the issue I increased it to 100,000 rows in order to see if it made a difference to the optimizer's selection. It did not, with 100k rows it was still doing a full table scan. My next step was to try

Probably bad index, full table scan

蹲街弑〆低调 提交于 2019-12-13 07:52:12
问题 Can you help me with index my tables? Problem is that i indexed my tables, but i still have "full table scan" in my explain this is my (working) query, but on big tables it could be slow, and i dont know how to change this EXPLAIN select * from stats_clicked s join visitor v on s.visitor_id=v.id ps. index3 - I dont wan't many times values (1,5) when visitor=1 refresh page with id=5 CREATE TABLE `visitor` ( `id` int(11) NOT NULL AUTO_INCREMENT, `visited_time` int(11) DEFAULT NULL, PRIMARY KEY

query efficiency - select the 2 latest “group/batch” records from table

落爺英雄遲暮 提交于 2019-12-12 01:25:42
问题 We have a tested a quite interesting SQL query. Unfortunately, It turned out that this query runs a little bit slow - O(n2) - and we are looking for a optimized solution or maybe also a totally different one? Goal: We would like to get for: - some customers ("record_customer_id"), e.g. ID 5 - the latest 2 "record_init_proc_id" - for every "record_inventory_id" http://www.sqlfiddle.com/#!9/07e5d/4 The query works fine and shows the correct results but uses at least two full table scans which

Why would Oracle ignore a “perfect” index?

寵の児 提交于 2019-12-05 01:07:07
问题 I have this table: create table demo ( key number(10) not null, type varchar2(3) not null, state varchar2(16) not null, ... lots more columns ... ) and this index: create index demo_x04 on demo(key, type, state); When I run this query select * from demo where key = 1 and type = '003' and state = 'NEW' EXPLAIN PLAN shows that it does a full table scan. So I dropped the index and created it again. EXPLAIN PLAN still says full table scan. How can that be? Some background: This is historical data