This simple query takes 2 hrs. How to improve it??
This is a simple query. It takes 2 hours to run this query. Tables have over 100,000 rows.
SELECT
TO_CHAR(BC_T_ARRIVALS.ARR_FLIGHT_DATE,'DD/MM/YYYY') ARR_FLIGHT_DATE
FROM
BC_T_ARRIVALS a, BC_M_FLIGHTS f
WHERE
a.ARR_FLT_SEQ_NO = f.FLT_SEQ_NO AND
f.FLT_LOC_CODE = PK_BC_R_LOCATIONS.FN_SEL_LOC_CODE('BANDARANAYAKE INTERNATIONAL AIRPORT') AND TO_CHAR(a.ARR_FLIGHT_DATE,'YYYY/MM/DD') >= TO_CHAR(:P_FROM_DATE,'YYYY/MM/DD')
AND TO_CHAR(a.ARR_FLIGHT_DATE,'YYYY/MM/DD') <= TO_CHAR(:P_TO_DATE,'YYYY/MM/DD')
UNION
SELECT
TO_CHAR(BC_T_DEPARTURES.DEP_FLIGHT_DATE,'DD/MM/YYYY') DEP_FLIGHT_DATE
FROM
BC_T_DEPARTURES d, BC_M_FLIGHTS f
WHERE
d.DEP_FLT_SEQ_NO = BC_M_FLIGHTS.FLT_SEQ_NO AND
f.FLT_LOC_CODE = PK_BC_R_LOCATIONS.FN_SEL_LOC_CODE('BANDARANAYAKE INTERNATIONAL AIRPORT') AND TO_CHAR(d.DEP_FLIGHT_DATE,'YYYY/MM/DD') >= TO_CHAR(:P_FROM_DATE,'YYYY/MM/DD')
AND TO_CHAR(d.DEP_FLIGHT_DATE,'YYYY/MM/DD') <= TO_CHAR(:P_TO_DATE,'YYYY/MM/DD')As I see it, this query will not make the DB engine use any indexes since expressions are used in the 'WHERE' clause. Am I correct?
How can we improve the performance of this query???
Maybe (do you really need to convert dates to chars ? That might prevent index use ...)
select f.BC_M_FLIGHTS,
TO_CHAR(BC_T_DEPARTURES.DEP_FLIGHT_DATE,'DD/MM/YYYY') DEP_FLIGHT_DATE,
TO_CHAR(BC_T_ARRIVALS.ARR_FLIGHT_DATE,'DD/MM/YYYY') ARR_FLIGHT_DATE
from (select BC_M_FLIGHTS,
FLT_LOC_CODE
from BC_M_FLIGHTS
where FLT_LOC_CODE = PK_BC_R_LOCATIONS.FN_SEL_LOC_CODE('BANDARANAYAKE INTERNATIONAL AIRPORT')
) f,
BC_T_ARRIVALS a,
BC_T_DEPARTURES d
where f.BC_M_FLIGHTS = a.ARR_FLT_SEQ_NO
and f.BC_M_FLIGHTS = d.DEP_FLT_SEQ_NO
and (TO_CHAR(a.ARR_FLIGHT_DATE,'YYYY/MM/DD') between TO_CHAR(:P_FROM_DATE,'YYYY/MM/DD') and TO_CHAR(:P_TO_DATE,'YYYY/MM/DD')
or TO_CHAR(d.DEP_FLIGHT_DATE,'YYYY/MM/DD') between TO_CHAR(:P_FROM_DATE,'YYYY/MM/DD') and TO_CHAR(:P_TO_DATE,'YYYY/MM/DD')
)Regards
Etbin
Edited by: Etbin on 2.3.2012 18:44
select column list altered
Similar Messages
-
Trying to optimize this simple query
Hi,
I am trying to optimize this simple query but the two methods I am trying actually make things worse.
The original query is:
SELECT customer_number, customer_name
FROM bsc_pdt_account_mv
where rownum <= 100
AND Upper(customer_name) like '%SP%'
AND customer_id IN
SELECT cust_id FROM bsc_pdt_assoc_sales_force_mv
WHERE area_identifier IN (
SELECT area_identifier FROM bsc_pdt_assoc_sales_force_mv
WHERE ad_identifier = '90004918' or rm_identifier = '90004918' or tm_identifier = '90004918'
The result set of this query returns me the first 100 rows in 88 seconds and they are all distinct by default (don't know why they are distinct).
My first attempt was to try to use table joins instead of the IN conditions:
SELECT
distinct -- A: I need to use distinct now
customer_number, customer_name
FROM bsc_pdt_account_mv pdt,
bsc_pdt_assoc_sales_force_mv asf,
SELECT distinct area_identifier FROM bsc_pdt_assoc_sales_force_mv
WHERE ad_identifier = '90004918' or rm_identifier = '90004918' or tm_identifier = '90004918'
) area
where
area.area_identifier = asf.area_identifier
AND asf.cust_id = pdt.customer_id
AND Upper(customer_name) like '%SP%'
AND rownum <= 100 -- B: strange when I comment this out
order by 1
I dont understand two things with this query. First issue, I now need to put in the distinct because the result set is not distinct by default. Second issue (very strange), when I put the rownum condition (<100) I get two rows in 1.5 seconds. If I remove the condition, I get 354 rows (whole result set) in 326 seconds.
My second attempt was to use EXISTS instead of IN:
SELECT
customer_number, customer_name
FROM bsc_pdt_account_mv pdt
where Upper(customer_name) like '%SP%'
AND rownum <= 100
AND EXISTS
select 1 from
bsc_pdt_assoc_sales_force_mv asf,
SELECT distinct area_identifier FROM bsc_pdt_assoc_sales_force_mv
WHERE ad_identifier = '90004918' or rm_identifier = '90004918' or tm_identifier = '90004918'
) area
where
area.area_identifier = asf.area_identifier
AND asf.cust_id = pdt.customer_id
This query returns a similar distinct result set as teh original one but takes pretty much the same time (87 seconds).The query below hangs when run in TOAD or PL/SQL Dev. I noticed there is no rows returned from the inner table for this condition.
SELECT customer_number, customer_name
FROM
bsc_pdt_account_mv pdt_account
where rownum <= 100
AND exists (
SELECT pdt_sales_force.cust_id
FROM bsc_pdt_assoc_sales_force_mv pdt_sales_force
WHERE pdt_account.customer_id = pdt_sales_force.cust_id
AND (pdt_sales_force.rm_identifier = '90007761' or pdt_sales_force.tm_identifier = '90007761') )
ORDER BY customer_name
-- No rows returned by this query
SELECT pdt_sales_force.cust_id
FROM bsc_pdt_assoc_sales_force_mv pdt_sales_force
WHERE pdt_sales_force.rm_identifier = '90007761' or pdt_sales_force.tm_identifier = '90007761' -
Simple query takes 18 minutes to retrieve data....
Hi,
I am facing this problem at the customer site where a simple query on a table takes 18 minutes or more. Please find below the details.
Table Structure
CREATE TABLE dsp_data
quantum_id NUMBER(11) NOT NULL,
src NUMBER(11) NOT NULL,
call_status NUMBER(11) NOT NULL,
dst NUMBER(11) NOT NULL,
measurement_id NUMBER(11) NOT NULL,
is_originating NUMBER(1) NOT NULL,
measurement_value NUMBER(15,4) NOT NULL,
data_type_id NUMBER(3) NOT NULL,
data VARCHAR2(200) NOT NULL
TABLESPACE dsp_data_tspace
STORAGE (PCTINCREASE 0 INITIAL 100K NEXT 1024K)
PARTITION BY RANGE (quantum_id)
(PARTITION dsp_data_default VALUES LESS THAN (100));
CREATE INDEX dsp_data_idx ON dsp_data
quantum_id,
src,
call_status,
dst,
measurement_id,
is_originating,
measurement_value,
data_type_id
TABLESPACE dsp_data_idx_tspace
LOCAL;
CREATE INDEX dsp_data_src_idx ON dsp_data
src
TABLESPACE dsp_data_idx_tspace
LOCAL;
CREATE INDEX dsp_data_dst_idx ON dsp_data
dst
TABLESPACE dsp_data_idx_tspace
LOCAL;
ALTER TABLE dsp_data
ADD CONSTRAINT fk_dsp_data_1
FOREIGN KEY
quantum_id
REFERENCES mds_measurement_intervals
quantum_id
ALTER TABLE dsp_data
ADD CONSTRAINT fk_dsp_data_2
FOREIGN KEY
data_type_id
REFERENCES mds_drilldown_types
type_id
ALTER TABLE dsp_data
ADD CONSTRAINT pk_dsp_data
PRIMARY KEY
quantum_id,
src,
call_status,
dst,
measurement_id,
is_originating,
measurement_value,
data_type_id,
data
USING INDEX
TABLESPACE dsp_data_idx_tspace
LOCAL;
Table Space Creation
All table space creation is done using following command
CREATE TABLESPACE [tablespaceName]
DATAFILE [tablespaceDatafile] SIZE 500M REUSE
AUTOEXTEND ON NEXT 10240K
DEFAULT STORAGE ( INITIAL 1024K
NEXT 1024K
MINEXTENTS 10
MAXEXTENTS UNLIMITED
PCTINCREASE 0
Server Configuration on CUtsomer Site
(1) 2 x Dual PA8900 Proc = 4GHz
(2) RAM = 16GB
(3) 3 x Internal HDDs
(4) 1 x External MSA-30 storage array (oracle db)
Record Information On Customer Site
select count(*) from dsp_data;
COUNT(*)
181931197
select min (quantum_id) from dsp_data where dst=2;
This takes 18 minutes or more....
SQL> SQL> SQL> explain plan for select min (quantum_id) from dsp_data where dst=2;
Explained.
SQL> @?/rdbms/admin/utlxpls
PLAN_TABLE_OUTPUT
Plan hash value: 999040277
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
| 0 | SELECT STATEMENT | | 1 | 14 | 1 (0)| 00:00:01 | | |
| 1 | SORT AGGREGATE | | 1 | 14 | | | | |
| 2 | FIRST ROW | | 92 | 1288 | 1 (0)| 00:00:01 | | |
| 3 | PARTITION RANGE ALL | | 92 | 1288 | 1 (0)| 00:00:01 | 1 | 29 |
|* 4 | INDEX FULL SCAN (MIN/MAX)| DSP_DATA_IDX | 92 | 1288 | 1 (0)| 00:00:01 | 1 | 29 |
As mentioned above the query takes 18 minutes or more. This is a critical issue at customer. Can you please give your suggestions how to improve and reduce the query time. Thanks in advance.Hi,
I did the following changes in the indexes of table.
drop index DSP_DATA_IDX;
create index DSP_DATA_MEASUREMENT_ID_IDX on DSP_DATA (MEASUREMENT_ID) TABLESPACE dsp_data_idx_tspace LOCAL;
After that I did explain plan,
explain plan for select min(QUANTUM_ID) from mds.DSP_DATA where SRC=11;
PLAN_TABLE_OUTPUT
| Id | Operation | Name | Rows | Bytes | Cost (%CPU
| 0 | SELECT STATEMENT | | 1 | 11 | 3 (0
| 1 | SORT AGGREGATE | | 1 | 11 |
| 2 | FIRST ROW | | 430K| 4626K| 3 (0
| 3 | PARTITION RANGE ALL | | 430K| 4626K| 3 (0
| 4 | INDEX FULL SCAN (MIN/MAX)| PK_DSP_DATA | 430K| 4626K| 3 (0
Note
- 'PLAN_TABLE' is old version
14 rows selected
SELECT table_name, index_name, monitoring, used FROM v$object_usage;
TABLE_NAME INDEX_NAME MONITORING USED
DSP_DATA DSP_DATA_SRC_IDX YES NO
It seems that DSP_DATA_SRC_IDX is not getting used in query. What changes do i need to make so that DSP_DATA_SRC_IDX index gets used.
Also, you have stated that to create global index on src and dst. How do i create them.
Thanks in Advance.
Edited by: 780707 on Jul 8, 2010 11:58 PM -
Simple query takes time to run
Hi,
I have a simple query whcih takes about 20 mins to run.. here is the TKPROF forit:
SELECT
SY2.QBAC0,
sum(decode(SALES_ORDER.SDCRCD,'USD', SALES_ORDER.SDAEXP,'CAD', SALES_ORDER.SDAEXP /1.0452))
FROM
JDE.F5542SY2 SY2,
JDE.F42119 SALES_ORDER,
JDE.F0116 SHIP_TO,
JDE.F5542SY1 SY1,
JDE.F4101 PRODUCT_INFO
WHERE
( SHIP_TO.ALAN8=SALES_ORDER.SDSHAN )
AND ( SY1.QANRAC=SY2.QBNRAC and SY1.QAOTCD=SY2.QBOTCD )
AND ( PRODUCT_INFO.IMITM=SALES_ORDER.SDITM )
AND ( SY2.QBSHAN=SALES_ORDER.SDSHAN )
AND ( SALES_ORDER.SDLNTY NOT IN ('H ','HC','I ') )
AND ( PRODUCT_INFO.IMSRP1 Not In (' ','000','689') )
AND ( SALES_ORDER.SDDCTO IN ('CO','CR','SA','SF','SG','SP','SM','SO','SL','SR') )
AND (
( SY1.QACTR=SHIP_TO.ALCTR )
AND ( PRODUCT_INFO.IMSRP1=SY1.QASRP1 )
GROUP BY
SY2.QBAC0
call count cpu elapsed disk query current rows
Parse 1 0.07 0.07 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 10 92.40 929.16 798689 838484 0 131
total 12 92.48 929.24 798689 838484 0 131
Misses in library cache during parse: 1
Optimizer goal: CHOOSE
Parsing user id: 62
Rows Row Source Operation
131 SORT GROUP BY
3535506 HASH JOIN
4026100 HASH JOIN
922 TABLE ACCESS FULL OBJ#(187309)
3454198 HASH JOIN
80065 INDEX FAST FULL SCAN OBJ#(30492) (object id 30492)
3489670 HASH JOIN
65192 INDEX FAST FULL SCAN OBJ#(30457) (object id 30457)
3489936 PARTITION RANGE ALL PARTITION: 1 9
3489936 TABLE ACCESS FULL OBJ#(30530) PARTITION: 1 9
97152 TABLE ACCESS FULL OBJ#(187308)
OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
call count cpu elapsed disk query current rows
Parse 1 0.07 0.07 0 0 0 0
Execute 2 0.00 0.00 0 0 0 0
Fetch 10 92.40 929.16 798689 838484 0 131
total 13 92.48 929.24 798689 838484 0 131
Misses in library cache during parse: 1kindly suggest how to resolve this...
OS is windows and its 9i DB...
Thanks> ... you want to get rid of the IN statements.
They prevent Oracle from usering the index.
SQL> create table mytable (id,num,description)
2 as
3 select level
4 , case level
5 when 0 then 0
6 when 1 then 1
7 else 2
8 end
9 , 'description ' || to_char(level)
10 from dual
11 connect by level <= 10000
12 /
Table created.
SQL> create index i1 on mytable(num)
2 /
Index created.
SQL> exec dbms_stats.gather_table_stats(user,'mytable')
PL/SQL procedure successfully completed.
SQL> set autotrace on explain
SQL> select id
2 , num
3 , description
4 from mytable
5 where num in (0,1)
6 /
ID NUM DESCRIPTION
1 1 description 1
1 row selected.
Execution Plan
Plan hash value: 2172953059
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 5001 | 112K| 2 (0)| 00:00:01 |
| 1 | INLIST ITERATOR | | | | | |
| 2 | TABLE ACCESS BY INDEX ROWID| MYTABLE | 5001 | 112K| 2 (0)| 00:00:01 |
|* 3 | INDEX RANGE SCAN | I1 | 5001 | | 1 (0)| 00:00:01 |
Predicate Information (identified by operation id):
3 - access("NUM"=0 OR "NUM"=1)Regards,
Rob. -
This SQLite query takes ages in Flash but not in SQLite Administrator
Hi
Are there ever occasions when flash adds time to queries?
I have a query that is taking almost 5 seconds on a database in Flash, yet when I put the same query into SQLite Administrator with that database loaded, it takes 15ms.
I set up a flash timer, and start it just before...
sqlStatement.execute(-1, new Responder( pass, fail ));
... and stop it and trace it as soon as Flash hits pass(); - so there's nothing else going on apart from the query to eat up time.
The database has an index that is being used according to EXPLAIN QUERY PLAN in SQLite Administrator. Does Flash use the same SQL code? It's as if it's ignoring the index.
Here's the query (I know there are a lot of COLLATE NOCASE statements - it's because my current table columns are not COLLATE NOCASE, and I'm not yet ready to set up a new table that has COLLATE NOCASE columns to copy the data into):
SELECT * FROM (SELECT * FROM table1 WHERE col1 !="" COLLATE NOCASE ORDER BY col1 COLLATE NOCASE , col2 COLLATE NOCASE ASC, col3 COLLATE NOCASE ASC, col4 COLLATE NOCASE ASC ) UNION ALL SELECT * FROM (SELECT * FROM table1 WHERE col1="" COLLATE NOCASE ORDER BY col2 COLLATE NOCASE ASC, col3COLLATE NOCASE ASC, col4 COLLATE NOCASE ASC) LIMIT 10
Other queries on the same database are very fast, and seem to take the same time in Flash and SQLite Administrator.
Thanks for your thoughts.You're limiting your results to 10, I'd also set the prefetch parameter of execute to 10 for posterity. Just a small thing.
How many columns are we talking about here? The SQL statement is fairly expensive (as you know) but I don't know how much data we're really talking about here or what the quality of the index tables are for this particular query. AIR also still needs to read and parse the result before handing it to you.
I'd go down the same route as you probably want to avoid. I'd trace every step of SQLConnection and SQLStatement to see exactly where the delay is occuring. I don't think you're going to get around this unless you just breakpoint from the connection and literally step through all the code yourself line by line until you notice the unusual delay and that isn't reliable because the delay could only occur when running the code full speed. I'd make sure you're running openAsync and trace every event and the timestamp on it (getTimer() - startTime). Something will show you the 4000-5000ms you're experiencing. -
Cant get this simple query!
Hi Guys,
There is this simple requirement of writing a query which will select most of the columns from a table but grouped on 3 columns from same table.
Table Str:
co11 col2 col3 col4 col5 col6 col7 col8 col9 col10
Required :
Group By: Col9, col10
Columns to be selected : co11 col2 col3 col4 col5 col6 col7 col8
I know there is something simple that I am missing.
any help will be appreciated.
Thanks!Hi,
This produces the output you requested fro the data you posted:
SELECT MIN (col1)
, MIN (col2)
, MIN (col3)
, MIN (col4)
, MIN (col5)
, MIN (col6)
, MIN (col7)
, MIN (col8)
, col9
, col10
FROM str
GROUP BY col9
, col10
;So does this
WITH got_rnum AS
SELECT str.*
, ROW_NUMBER () OVER ( PARTITION BY col9
, col10
ORDER BY col1
, col2
, col3
, col4
, col5
, col6
, col7
, col8
) AS rnum
FROM str
SELECT col1
, col2
, col3
, col4
, col5
, col6
, col7
, col8
, col9
, col10
FROM got_rnum
WHERE rnum = 1
;With the sample data you posted, the two queries produce the same results.
With some other data, the two queries will produce different results. -
What is wrong with this simple query
Hi,
I am writting a simple code just to get the maximum no values from a database table
The query is
ResultSet = stm.executeQuery("SELECT MAX(column_name) FROM Database_table ");
it seems to be a simple one but i am getting the message
column not found
Please answer soonWell, it depends on how your resultset is retrieving the results. If you retrieve by column name, then that's your problem. You need to do something like this:
ResultSet = stm.executeQuery("SELECT MAX(column_name) AS myColumnName FROM Database_table ");
String myResult = ResultSet.getString(myColumnName);Using MAX, COUNT, etc, will return your result with a mangled or no actual column name to retrieve from. Optionally, you can solve your problem by:
ResultSet.getString(1);Michael Bishop -
Why is this simple query failing?
Select T0.[docentry], charindex('-', T0.[U_I_LongDesc])
from [dbo].[RDR1] T0
Gives "Must specify table to select from".
This works fine (without charindex):
Select T0.[docentry], T0.[U_I_LongDesc]
from [dbo].[RDR1] T0
Also the original query works fine in MS SQL Server Management Studio.
What behind-the-scenes garbage is SAP doing now (like adding "FOR BROWSE" to every select)?Thanks Gordon. You're right it does work on system fields. After some further digging it appears the problem must be that all alphanumeric UDF's are created as nvarchar(max) in SQL Server, regardless of the length you specify.
This seems to be a bug in SAP. The charindex query above fails on all UDF's.
I defined U_I_LongDesc as Alphanumeric (100) in SAP. Here's what I see defined in SQL Server Management Studio:
Dscription (nvarchar(100), null) /* SAP field with correct length */
U_I_LongDesc (nvarchar(max), null) /* UDF. Gets set to max for all Alphanumeric fields */ -
Wat is wrong with this simple query ???
I am using 10gxe.
Below is the query which is not working
Whenever i am executing it a pop up windows is coming up
and asking me to enter bind variables ..wat shall i do ???
Here is a prntscrn of the issue .
http://potupaul.webs.com/at.html
VARIABLE g_message VARCHAR2(30)
BEGIN
:g_message := 'My PL/SQL Block Works';
END;
PRINT g_message
Edited by: user4501184 on May 18, 2010 12:42 AMsqlplus "system/sm@test"
SQL*Plus: Release 10.2.0.2.0 - Production on Tue May 18 12:45:05 2010
Copyright (c) 1982, 2005, Oracle. All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> VARIABLE g_message VARCHAR2(30)
SQL> BEGIN
2 :g_message := 'My PL/SQL Block Works';
3 END;
4 /
PL/SQL procedure successfully completed.
SQL> PRINT g_message;
G_MESSAGE
My PL/SQL Block Works
SQL> -
Hi,
I'm using Oracle 10g r2.
I have this simple query that seems to take too much time to execute :
DECLARE
nb_mesures INTEGER;
min_day DATE;
max_day DATE;
BEGIN
SELECT
COUNT(meas_id),
MIN(meas_day),
MAX(meas_day)
INTO
nb_mesures,
min_day,
max_day
FROM
geodetic_measurements gm
INNER JOIN
operation_measurements om
ON gm.meas_id = om.ogm_meas_id
WHERE ogm_op_id = 0;
htp.p(nb_mesures||' measurements from '||min_day||' to '||max_day);
END;- Tables (about 11.000 records for the "Operations" table, and 800.000 for the 2 others) :
"Operation_measurements" is the table who makes the link between the 2 others (get the 2 keys).
SQL> DESCRIBE OPERATIONS
Nom NULL Type
OP_ID NOT NULL NUMBER(7)
OP_PARENT_OP_ID NUMBER(7)
OP_RESPONSIBLE NOT NULL VARCHAR2(10)
OP_DESCRIPT VARCHAR2(80)
OP_VEDA_NAME NOT NULL VARCHAR2(10)
OP_BEGIN NOT NULL DATE
OP_END DATE
OP_INSERT_DATE DATE
OP_LAST_UPDATE DATE
OP_INSERT_BY VARCHAR2(50)
OP_UPDATE_BY VARCHAR2(50)
SQL> DESCRIBE OPERATION_MEASUREMENTS
Nom NULL Type
OGM_MEAS_ID NOT NULL NUMBER(7)
OGM_OP_ID NOT NULL NUMBER(6)
OGM_INSERT_DATE DATE
OGM_LAST_UPDATE DATE
OGM_INSERT_BY VARCHAR2(50)
OGM_UPDATE_BY VARCHAR2(50)
SQL> DESCRIBE GEODETIC_MEASUREMENTS
Nom NULL Type
MEAS_ID NOT NULL NUMBER(7)
MEAS_TYPE NOT NULL VARCHAR2(2)
MEAS_TEAM NOT NULL VARCHAR2(10)
MEAS_DAY NOT NULL DATE
MEAS_OBJ_ID NOT NULL NUMBER(6)
MEAS_STATUS VARCHAR2(1)
MEAS_COMMENT VARCHAR2(150)
MEAS_DIRECTION VARCHAR2(1)
MEAS_DIST_MODE VARCHAR2(2)
MEAS_SPAT_ID NOT NULL NUMBER(7)
MEAS_INST_ID NUMBER(7)
MEAS_DECALAGE NUMBER(8,5)
MEAS_INST_HEIGHT NUMBER(8,5)
MEAS_READING NOT NULL NUMBER(11,5)
MEAS_CORRECT_READING NUMBER(11,5)
MEAS_HUMID_TEMP NUMBER(4,1)
MEAS_DRY_TEMP NUMBER(4,1)
MEAS_PRESSURE NUMBER(4)
MEAS_HUMIDITY NUMBER(2)
MEAS_CONSTANT NUMBER(8,5)
MEAS_ROLE VARCHAR2(1)
MEAS_INSERT_DATE DATE
MEAS_LAST_UPDATE DATE
MEAS_INSERT_BY VARCHAR2(50)
MEAS_UPDATE_BY VARCHAR2(50)
MEAS_TILT_MODE VARCHAR2(4000) - Explain plan (I'm not familiar with explain plans...) :
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
PLAN_TABLE_OUTPUT
| 0 | SELECT STATEMENT | | 1 | 19 | 256 (10)| 00:00:02 |
| 1 | SORT AGGREGATE | | 1 | 19 | | |
| 2 | NESTED LOOPS | | 75 | 1425 | 256 (10)| 00:00:02 |
|* 3 | TABLE ACCESS FULL | OPERATION_MEASUREMENTS | 75 | 600 | 90 (27)| 00:00:01 |
| 4 | TABLE ACCESS BY INDEX ROWID| GEODETIC_MEASUREMENTS | 1 | 11 | 3 (0)| 00:00:01 |
|* 5 | INDEX UNIQUE SCAN | MEAS_PK_2 | 1 | | 2 (50)| 00:00:01 |
--------------------------------------------------------------------------------------------------------How can I optimize this query ?
Thanks.
Yann.Looks like you are missing an FK-index on the middle table, for the FK going to OPERATIONS.
Currently this:
WHERE ogm_op_id = 0;Is computed via a full table scan followed by a filter operation. Assuming OP_ID is rather selective, an index on OGM_OP_ID could do the trick here. -
6 million + records, query takes more than 50 min to execute.
Hi
I am trying to get records from a table which has more than 6 million of records.
The value set of the particular col IND can be
NULL
'0'
'1'
and other value like A B '6'
The data type of IND is varchar.
I want all the records where the value is other than NULL, 0 and 1
I tried this simple query
SELECT ID, IND
FROM tablename
WHERE
IND IS NOT NULL
AND IND <> '0'
AND IND <> '1'
Now this query is taking more than 30-40 min. Is this a way I can speed up this query. Also I can't index on the column.
any suggestions ?I don't know anything about your tables or hardware (nor your Oracle version because you didn't post it) but 30 - 40 minutes seems excessive for a full table scan on only 6 million rows.
On my lowly test instance, this full table scan takes a little over a minute:
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 4 | 4800 (2)| 00:01:11 |
| 1 | SORT AGGREGATE | | 1 | 4 | | |
| 2 | TABLE ACCESS FULL| ATLAS_SALES_HISTORY | 6618K| 25M| 4800 (2)| 00:01:11 |
Statistics
631 recursive calls
0 db block gets
55740 consistent gets
55609 physical reads
0 redo size
415 bytes sent via SQL*Net to client
346 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
15 sorts (memory)
0 sorts (disk)
1 rows processedAre you pulling all 6 million rows across the network to your client machine? (And waiting for the rows to scroll?) -
Dear Experts,
Not able to Execute this simple query :
Select T1.JobID , T1.BudgetValue,T1.ActualValue FROM [dbo].[Enprise_JobCost_ActualBudgetView] T1 WHERE T1.TransType = '[%0]'
RegardsHello,
View - A View in simple terms is a subset of a 'virtual table. It can be used to retrieve data from the tables, Insert, Update or Delete from the tables. The Results of using View are not permanently stored in the database.
Stored Procedure - A stored procedure is a group of SQL statements which can be stored into the database and can be shared over the netwrok with different users.
http://www.geekinterview.com/question_details/65914
Better make a UDT for your requirement.
Thanks
Manvendra Singh Niranjan -
How to improve performance in the following PL/SQL
I'm running this PL/SQL in a Job step inside a UNIX job, is taking too long to finish and is a simple process to do but definetely there is something that I need to do.
I have to find records that are not included in my T_XREF table from my temporary table T_TEMP, identify those records and insert a new record with values located in the T_TEMP table into the T_XREF table.
T_TEMP has 2 millions records and T_XREF has 12,000 records, I have a Unique IDX in T_TEMP (claim,num_dtl) and a NON UNIQUE IDX by (7 fields).
on the T_XREF table I have 1 UNIQUE IDX (comp_key).
this is part of the PL/SQL:
DECLARE
v_rowid ROWID;
CURSOR c_FixComp1 IS
SELECT DISTINCT sak_acct,ind_split,cde_state,cde_fed,med_a,med_b,ind_cnty
FROM T_TEMP
WHERE claim >= 0;
BEGIN
FOR r_FixComp1 IN c_FixComp1 LOOP
BEGIN
SELECT ROWID
INTO v_rowid
FROM T_XREF x
WHERE x.sak_acct = r_FixComp1.sak_acct
AND x.ind_split = r_FixComp1.ind_split
AND x.cde_state = r_FixComp1.cde_state
AND x.cde_fed = r_FixComp1.cde_fed
AND x.med_a = r_FixComp1.med_a
AND x.med_b = r_FixComp1.med_b
AND x.ind_cnty = r_FixComp1.ind_cnty;
EXCEPTION
WHEN NO_DATA_FOUND THEN
INSERT INTO T_XREF
(comp_key,
sak_acct,
ind_split,
cde_state,
cde_fed,
med_a,
med_b,
ind_cnty)
VALUES
(seq_xref.Nextval,
r_FixComp1.sak_acct,
r_FixComp1.ind_split,
r_FixComp1.cde_state,
r_FixComp1.cde_fedt,
r_FixComp1.med_a,
r_FixComp1.med_b,
r_FixComp1.ind_cnty);
WHEN OTHERS THEN
cnt_notinserted := cnt_notinserted + 1;
END;
END LOOP;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
END;
in my Cursor's query I'm forcing to do a IDX (range scan) and the result of that query is only 1300 rec after doing the DISTINCT of those fields. When starts analyzing record by record this simple script takes more than 10 hrs to run!!!
I'll appreciate any advice you can give me. ThanksThe reason your code is slow is that you are doing something that wasn't even best practice in version 7.0.12. Chris Poole is absolutely correct: There is no reason for any procedural code.
Even if there were a valid reason for PL/SQL the row-by-row cursor fetch construct has been obsolete for 6 years.
Do what Chris is suggesting here and then put away the cursor loops and learn how to write this code:
http://www.psoug.org/reference/array_processing.html
Check out the SLOW_WAY and FAST_WAY demos. -
How to Improve the performance in Variable Selection Screen.
Hi,
In Query Level we have Variable " User entry Defalt Valu". User want select particular value when he press "F4" it's take hours time how to improve the performance in Varaible Selection Screen.
Thanks in Advance.
Regards,
Venkat.Dear Venkat.
You please try the following steps:
1. Say the InfoObject is 0EMPLOYEE against which you have created the variable, which user is trying to select value against, when they execute the report.
2. Goto RSA1-> InfoObject tab-> Select InfoObject 0EMPLOYEE.
3. Selcet the following options:
Query Execution Filter Val. Selectn - 'Only Posted Value for Navigation'
Filter Value Repr. At Query Exec. - 'Selector Box Without Values'
Please let me know if there is any more issue. Feel free to raise further concern
Thnx,
Sukdev K -
Tutorial: How To Improve YouTube Playback on iBook G3 (Dual USB)
Disclaimer: Apple does not necessarily endorse any suggestions, solutions, or third-party software products that may be mentioned in the topic below. Apple encourages you to first seek a solution at Apple Support. The following links are provided as is, with no guarantee of the effectiveness or reliability of the information. Apple does not guarantee that these links will be maintained or functional at any given time. Use the information below at your own discretion.
This is a brief tutorial on how to improve YouTube video playback on an Apple iBook G3. As of now, I have only tested this method on my own iBook. iBook's with lower specs than the 900 MHz model may not receive the same performance upgrade from this brief tutorial. With that said, here is what you can do to attempt to make YouTube more functional on your iBook G3.
1) If the iBook is running Mac OS X 10.4 (Tiger), disable Dashboard and Spotlight:
While widgets are fun and Spotlight is a useful quick search tool, they are known resource consumers that make video playback problematic for older Mac laptops, such as the iBook G3. To accomplish this, you will have to use the Terminal. Once the Terminal is open, enter the following command
{color:purple}defaults write com.apple.dashboard mcx-disabled -boolean YES{color}
After entering this command, you will then need to restart the Dock (Dashboard is owned by the Dock). To do so, again, using the Terminal, you will enter the following command.
{color:purple}killall Dock{color}
You may still see the Dashboard icon in the Dock, but clicking on it should do nothing.
For the next part, you will use the Terminal to disable Spotlight. Open the Terminal and enter the following command.
{color:purple}sudo nano /etc/hostconfig{color}
This will bring up a configuration listing. Use the arrow keys to scroll down and change the value, SPOTLIGHT=-YES-, to SPOTLIGHT=-NO-.
From here, you should press Ctrl+X to exit, upon which it will ask if you want to save. Follow the on screen prompts to save, and exit out of the Terminal. Spotlight will still appear in the corner of your screen, but it won't search for anything. Now on to the next step.
2) For any video URL on YouTube, add &fmt=5 to the end of the URL, and this will force videos to run in quarter VGA mode (320x240). The video quality will be degraded, but you should maintain a stable frame rate that is uninterrupted and capable of streaming without the need to pause and wait for the entire video to load.
This method has worked for me for old and new videos alike. Unfortunately, I have not found a way to make iTunes/Quicktime force videos into a low resolution mode, so this fix will only resolve video playback involving YouTube.
*To restore functionality to Dashboard and Spotlight:*
1) How to Restore the Dashboard
Open the terminal and input the following command
{color:purple}defaults write com.apple.dashboard mcx-disabled -boolean NO {color}
After entering this command, you will have to restart the Dock. To do so, enter the following command into the terminal
{color:purple}killall Dock{color}
Now, can drag the Dashboard icon back to the Dock, or if you did not remove it to begin with, it should function once again.
2) How to restore Spotlight
Open the terminal and enter the following command
{color:purple}sudo nano /etc/hostconfig{color}
This will open up a config file. Scroll down (using the arrow keys) to the portion that says SPOTLIGHT=-NO- and change the value so that it says SPOTLIGHT=-YES-
Exit the config file by pressing Ctrl+X. Follow the onscreen prompts to save the config file, and you are allset.
Best of luck to you all. I hope that this tutorial has been helpful.
This is the 2nd version of this tip. It was submitted on May 19, 2010 by Macology, with thanks to Ronda Wilson.
Do you want to provide feedback on this User Contributed Tip or contribute your own? If you have achieved Level 2 status, visit the User Tips Library Contributions forum for more information.Disclaimer: Apple does not necessarily endorse any suggestions, solutions, or third-party software products that may be mentioned in the topic below. Apple encourages you to first seek a solution at Apple Support. The following links are provided as is, with no guarantee of the effectiveness or reliability of the information. Apple does not guarantee that these links will be maintained or functional at any given time. Use the information below at your own discretion.
This is a brief tutorial on how to improve YouTube video playback on an Apple iBook G3. As of now, I have only tested this method on my own iBook. iBook's with lower specs than the 900 MHz model may not receive the same performance upgrade from this brief tutorial. With that said, here is what you can do to attempt to make YouTube more functional on your iBook G3.
1) If the iBook is running Mac OS X 10.4 (Tiger), disable Dashboard and Spotlight:
While widgets are fun and Spotlight is a useful quick search tool, they are known resource consumers that make video playback problematic for older Mac laptops, such as the iBook G3. To accomplish this, you will have to use the Terminal. Once the Terminal is open, enter the following command
{color:purple}defaults write com.apple.dashboard mcx-disabled -boolean YES{color}
After entering this command, you will then need to restart the Dock (Dashboard is owned by the Dock). To do so, again, using the Terminal, you will enter the following command.
{color:purple}killall Dock{color}
You may still see the Dashboard icon in the Dock, but clicking on it should do nothing.
For the next part, you will use the Terminal to disable Spotlight. Open the Terminal and enter the following command.
{color:purple}sudo nano /etc/hostconfig{color}
This will bring up a configuration listing. Use the arrow keys to scroll down and change the value, SPOTLIGHT=-YES-, to SPOTLIGHT=-NO-.
From here, you should press Ctrl+X to exit, upon which it will ask if you want to save. Follow the on screen prompts to save, and exit out of the Terminal. Spotlight will still appear in the corner of your screen, but it won't search for anything. Now on to the next step.
2) For any video URL on YouTube, add &fmt=5 to the end of the URL, and this will force videos to run in quarter VGA mode (320x240). The video quality will be degraded, but you should maintain a stable frame rate that is uninterrupted and capable of streaming without the need to pause and wait for the entire video to load.
This method has worked for me for old and new videos alike. Unfortunately, I have not found a way to make iTunes/Quicktime force videos into a low resolution mode, so this fix will only resolve video playback involving YouTube.
*To restore functionality to Dashboard and Spotlight:*
1) How to Restore the Dashboard
Open the terminal and input the following command
{color:purple}defaults write com.apple.dashboard mcx-disabled -boolean NO {color}
After entering this command, you will have to restart the Dock. To do so, enter the following command into the terminal
{color:purple}killall Dock{color}
Now, can drag the Dashboard icon back to the Dock, or if you did not remove it to begin with, it should function once again.
2) How to restore Spotlight
Open the terminal and enter the following command
{color:purple}sudo nano /etc/hostconfig{color}
This will open up a config file. Scroll down (using the arrow keys) to the portion that says SPOTLIGHT=-NO- and change the value so that it says SPOTLIGHT=-YES-
Exit the config file by pressing Ctrl+X. Follow the onscreen prompts to save the config file, and you are allset.
Best of luck to you all. I hope that this tutorial has been helpful.
This is the 2nd version of this tip. It was submitted on May 19, 2010 by Macology, with thanks to Ronda Wilson.
Do you want to provide feedback on this User Contributed Tip or contribute your own? If you have achieved Level 2 status, visit the User Tips Library Contributions forum for more information.
Maybe you are looking for
-
Error when displaying web reports
Hello, Our client have a problem with the character set of web application built using WAD 3.5 in a BW 7.0 system. Java stack is not installed and WAD 3.5 is therefore still in use. New web applications looks ok when executed directly from WAD. But w
-
When I try to poen a file a receive an error image "the specified module could not be found.C:\programFiles\common Files\adobe\adobe Version CyeCs3|3.1.0\VersionCueUI.DLL". When I tried to reinstall it, I only end up having only DreamweaverCS3 reinst
-
This first started happening RIGHT AWAY after I downloaded CC on my previous iMac. After downloading a program from CC I could use it like once or twice, and then it would just stop opening. The opening icon pops up for a millisecond in the bottom ri
-
How to print a field on the last page of Smartform?
HI FRIENDS, I NEED TO PRINT ONLY ONE FIELD IN LAST PAGE OF FORM SMARTFORM HOW DO I CHECK last page. I tried WITH THE FIELDS OF TABLE SYSF BUT NOT worked. Thank you. ROGERIO VAZ
-
When is the next FB 4.7 Update?
It has been quite some time since FB 4.7 was released and there haven't been any bug-fixing updates so far. Also, Java 7 is not fully supported (at least in OS X). Can we expect anything in the near future?