oracle - The fast way to select with where cause -
i have table 10 million records have table structure this
------------------------------------------- barcode | price | brand ------------------------------------------- 1001001000111 | 1 usd | 1001001000112 | 1 usd | b 1001001000113 | 1 usd | 1001001000114 | 1 usd | b 1001001000115 | 1 usd | c . . .
i want barcode value brand equal b; query.
select barcode mytable brand='b';
i spent lot of time wait result, try change where
condition where brand='b'
brand not in ('a','b','c',..)
. seem faster first query amount of element in ('a','b','c',..)
small, amount of elements in ('a','b','c','d',...)
getting huge query getting slower.
what fastest way data?
please me solve this.
if there no index on brand end doing full table scan.
if there index on brand, large fraction of table brand b query optimizer may decide full table scan still best method.
if there index on brand, , b selective representing relatively small fraction of table, optimizer still choosing full table scan, statistics may stale , should try gathering fresh stats on table.
Comments
Post a Comment