473,414 Members | 1,862 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Slow query on date field via views

I have several views with unions, outer joints and calculations that later combine to find a "final"
report view.
This was to make things easier for the web-based report programmer to just pull the values from this
view.

If I query the view by the id/index/primary_key, the view runs fine (about 3secs)

e.g: Select *
from final_view
where Id_Index in (123, 456, 789)

However, when the view is queried by dates, it is slow.
More like impossible actually 'cos the temp table space gets filled up (32GB!) and oracle returns an
error about
being unable to extend.

E.g: Select *
from final_view
where Submission_Date=to_date('01-01-2005', 'dd-mm-yyyy')
I tried indexing the Sub_Date but it didn't help.

But if I run the query directly on the table in question (with the sub_date), the query works fine &
fast,
with or without the indexing.

Anyone got any pointers?

I'm using oracle 9i.
And the 3 big tables which the view taps on have about 100,000 records each.
Thanks

To e-mail, remove the obvious
May 10 '06 #1
2 11399
Sybrand Bakker <post...@sybrandb.demon.nl> wrote:
Did you get the explain plans and compare them?
Please get the explain plans and post them here. --
Sybrand Bakker, Senior Oracle DBA


Ok, after much fiddling around and running sqlanalyze I was able to optimize the query pretty well.
It told me to use a "union all" instead of "union". I hope I don't end up with dupe rows.
That did help pretty much.

However, it still took me 25 secs to run the below query:

Select w.*
from client.weekly_report_details w
where w.submission_date between to_date('17-Apr-2005', 'DD-MON-YYYY') and to_date('30-Apr-2005',
'DD-MON-YYYY')
and w.adv_id=42

If I use the index then it runs about 2 secs:

Select w.*
from client.weekly_report_details w
where w.submission_date between to_date('17-Apr-2005', 'DD-MON-YYYY') and to_date('30-Apr-2005',
'DD-MON-YYYY')
and w.policy_id in (63771, 63923, 63924)

I found more nasties in the jsp report the vendor wrote.
He was using to_char() on the date fields.

My plan table seems to be pretty big :)
I have no idea how to read it.

I hope a small binary does not irk people here

Thanks

To e-mail, remove the obvious
May 16 '06 #2
Sybrand Bakker <post...@sybrandb.demon.nl> wrote:
Did you get the explain plans and compare them?
Please get the explain plans and post them here. --
Sybrand Bakker, Senior Oracle DBA


Ok, after much fiddling around and running sqlanalyze I was able to optimize the query pretty well.
It told me to use a "union all" instead of "union". I hope I don't end up with dupe rows.
That did help pretty much.

However, it still took me 25 secs to run the below query:

Select w.*
from client.weekly_report_details w
where w.submission_date between to_date('17-Apr-2005', 'DD-MON-YYYY') and to_date('30-Apr-2005',
'DD-MON-YYYY')
and w.adv_id=42

If I use the index then it runs about 2 secs:

Select w.*
from client.weekly_report_details w
where w.submission_date between to_date('17-Apr-2005', 'DD-MON-YYYY') and to_date('30-Apr-2005',
'DD-MON-YYYY')
and w.policy_id in (63771, 63923, 63924)

I found more nasties in the jsp report the vendor wrote.
He was using to_char() on the date fields.

My plan table seems to be pretty big :)
I have no idea how to read it.

I hope a small binary does not irk people here

Thanks

To e-mail, remove the obvious
May 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: YoBro | last post by:
Hi, I have a database that stores in a field the number of views for a product. I want to write a query that gets the two highest views, so I can then output the result. I have this so far,...
6
by: Umar Farooq | last post by:
Hello all, Please bear with the long explanation of my scenario. As I'm relatively new to the query world, I like to write my queries using the visual toos such as the "View" option in SQL...
5
by: krystoffff | last post by:
I currently have PostgreSQL 7.1 installed on a server with about 700 Mb of RAM. I have many problems of speed with a database I created. For example, it took almost 12 sec to run the query...
15
by: Rolan | last post by:
There must be a way to enhance the performance of a query, or find a plausible workaround, but I seem to be hitting a wall. I have tried a few tweaks, however, there has been no improvement. ...
4
by: cefrancke | last post by:
Are there any ways to speed up a Cumulative sum in a query or perhaps another faster way to have a cumulative sum column (call a vba function?). For example, I want to sum up all values under...
1
by: jpatchak | last post by:
Hi Guys, Sorry if this is a really stupid question. I am trying to upsize my Access database to SQL server. When I used the Access upsizing wizard, some of my queries didn't get upsized so I am...
9
by: Emin | last post by:
Dear Experts, I have a fairly simple query in which adding a where clause slows things down by at least a factor of 100. The following is the slow version of the query ...
3
by: Antoni | last post by:
Hello, I have a table with more than 1,000,000 rows. mysqldescribe views_date; +----------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key |...
2
by: AcCeSsDeNiEd | last post by:
I have several views with unions, outer joints and calculations that later combine to find a "final" report view. This was to make things easier for the web-based report programmer to just pull the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.