473,378 Members | 1,441 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,378 software developers and data experts.

How to improve a simple SQL performance

Hi Dear All,

I have a large query as below:
select count (distinct b.bus_acct_id) from
M_DATE M1,
M_BIZ_ACCT M2,
BIZ_ACCT B,
C_PRDT_PKG C
where
M1.month_id = M2.month_id
and M2.CDS_PROD_PKG_ID = c.CDS_PROD_PKG_ID
and M2.Bus_Acct_Id = B.Bus_Acct_Id

There are 4 tables , M_DATE , has 100 rows, M1 stands for it,
M_BIZ_ACCT, Has 2.5 Million rows, M2 stands for it,
BIZ_ACCT, Has 1 Million rows, B stands for it,
C_PRDT_PKG , has 20 rows, C atands for it.

This SQL take about 10-15 minutes, it is Oracle 8.1.7.4.0,

Is there anyway to improve performance by change
the SQL I used, such as change order of tables list,

because 2 of the them are small, the other 2 are very large,
Thanks
Jul 19 '05 #1
2 4868
"ALex_1998" <mi******@yahoo.com> wrote in message
news:4b**************************@posting.google.c om...
Hi Dear All,

I have a large query as below:
select count (distinct b.bus_acct_id) from
M_DATE M1,
M_BIZ_ACCT M2,
BIZ_ACCT B,
C_PRDT_PKG C
where
M1.month_id = M2.month_id
and M2.CDS_PROD_PKG_ID = c.CDS_PROD_PKG_ID
and M2.Bus_Acct_Id = B.Bus_Acct_Id

There are 4 tables , M_DATE , has 100 rows, M1 stands for it,
M_BIZ_ACCT, Has 2.5 Million rows, M2 stands for it,
BIZ_ACCT, Has 1 Million rows, B stands for it,
C_PRDT_PKG , has 20 rows, C atands for it.

This SQL take about 10-15 minutes, it is Oracle 8.1.7.4.0,

Is there anyway to improve performance by change
the SQL I used, such as change order of tables list,

because 2 of the them are small, the other 2 are very large,
Thanks


What is the explain plan, what is the tkprof output , are the tables
analyzed, what indexes do you have?
Jim
Jul 19 '05 #2
mi******@yahoo.com (ALex_1998) wrote in message news:<4b**************************@posting.google. com>...
Hi Dear All,

I have a large query as below:
select count (distinct b.bus_acct_id) from
M_DATE M1,
M_BIZ_ACCT M2,
BIZ_ACCT B,
C_PRDT_PKG C
where
M1.month_id = M2.month_id
and M2.CDS_PROD_PKG_ID = c.CDS_PROD_PKG_ID
and M2.Bus_Acct_Id = B.Bus_Acct_Id

There are 4 tables , M_DATE , has 100 rows, M1 stands for it,
M_BIZ_ACCT, Has 2.5 Million rows, M2 stands for it,
BIZ_ACCT, Has 1 Million rows, B stands for it,
C_PRDT_PKG , has 20 rows, C atands for it.

This SQL take about 10-15 minutes, it is Oracle 8.1.7.4.0,

Is there anyway to improve performance by change
the SQL I used, such as change order of tables list,

Run explain plan for the query. Make sure that m_biz_acct is a
driving table and Oracle uses full table scan on it. That is,
if you don't have an index which includes all three fields
mentioned in the query. If such an index exists, full index
scan on it is the best solution.
Actually, cost based optimized should've figured it all out,
if the tables and indexes are analyzed.
You may also try to increase hash area size for the session,
use full table scan on both big tables and use hash join
to join them.
because 2 of the them are small, the other 2 are very large,
Thanks

Jul 19 '05 #3

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

Similar topics

5
by: charlies224 | last post by:
Hi, I am using SQL 2000 and has a table that contains more than 2 million rows of data (and growing). Right now, I have encountered 2 problems: 1) Sometimes, when I try to query against this...
9
by: Peng Jian | last post by:
I have a function that is called very very often. Can I improve its efficiency by declaring its local variables to be static?
65
by: Skybuck Flying | last post by:
Hi, I needed a method to determine if a point was on a line segment in 2D. So I googled for some help and so far I have evaluated two methods. The first method was only a formula, the second...
1
by: Lakesider | last post by:
Hi NG, I have written an application with a lot of file- and database operations. There are several algorithmic operations, too. My question is: are ther any tools to improve performance -...
6
by: Jéjé | last post by:
Hi, hoew can I improve the compilation process of a sharepoint website? my server is: 2 * P3 Xeom 1ghz 4go ram 2 * 36gb (mirror for OS and website) 2 * 36 Raid 0 (stripping; for temp files...
1
by: Oberfuhrer | last post by:
Hello all VB.net friends ! i have done most of my programming in assembly, at least so far. Recently i decided to learn a high level language for windows programming. I didnt take long to...
11
by: Paul H | last post by:
Suppose I have a table called tblPeople and I want a field to illustrate whether each person prefers cats or dogs. I could do it one of three ways. 1. A plain text field Create a text field in...
2
by: sdanda | last post by:
Hi , Do you have any idea how to improve my java class performance while selecting and inserting data into DB using JDBC Connectivity ......... This has to work for more than 8,00,000...
5
by: Gilles Ganault | last post by:
Hello I'm no PHP expert, and I'm reading "Building scalable web sites". In the tips section, the author mentions using templates to speed things up. I was wondering how the template engines...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.