472,353 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

performance increase - help needed

1
Hello,

This is regarding log analysis of a web system, I am finding my backend SQL programming has taken so much of time to process the application due to following quires for a log table having 500 million records, i have already done index tuning , but no use, so I would like to change the following quires into a single stored procedure in order to reduce Client server network traffic and to increase performance.

Anybody can help me to identify, how to write or how to modify the following T-SQL code to tune high performance Stored Procedure,

This is a query about to identify the 'Countries' and access 'Pages' from a W3C formatted Log DB Table.
- Means which country accessed for a particular web page and date
- Total hit count from particular country for the particular date
- Total hit count (TOP 3) of a page, which was accessed maximum for the particular date

Query A : Selecting Country ID , Country Name and Total Hit Count of particular day
----------------------------------------------------------------
SELECT
NewLog_T.country as countryid,
Level1Domain_M.Country_j as countryname,
COUNT(NewLog_T.csUriStem) as hitcount
FROM
NewLog_T,
Page_M,
Level1Domain_M
WHERE
Level1Domain_M.Level1DomainName = NewLog_T.country AND
SUBSTRING(NewLog_T.date,1,4) = '2005' AND
SUBSTRING(NewLog_T.date,6,2) = '08' AND
SUBSTRING(NewLog_T.date,9,2) = '29' AND
'http://www.testserver.com'+NewLog_T.csUriStem = Page_M.URL
GROUP BY
NewLog_T.country,
Level1Domain_M.Country_j
ORDER BY
hitcount desc;
----------------------------------------------------------------

Query B :
Selecting Page Name, Page Hitcount, Total Access Count (particular country - results from Query A)
and Grand Total Access Count (from all countries)
---------------------------------------------------------------
SELECT TOP 3
Page_M.PageName as pagetitle,
COUNT(NewLog_T.csUriStem) as pagehitcount,
TotalCount.hitcount as totalcount,
GrandTotalCount.hitcount as grandtotalcount
FROM
NewLog_T,
Page_M,
(SELECT
sum(mid_TotalCount.mid_hitcount) as hitcount
FROM
(SELECT
COUNT(NewLog_T.csUriStem) as mid_hitcount
FROM
NewLog_T,
Page_M
WHERE
SUBSTRING(NewLog_T.date,1,4) = '2005' AND
SUBSTRING(NewLog_T.date,6,2) = '08' AND
SUBSTRING(NewLog_T.date,9,2) = '29' AND
'http://www.testserver.com'+NewLog_T.csUriStem = Page_M.URL AND
NewLog_T.country = 'SG' ---------------------> to be set from QUERY A output
GROUP BY
Page_M.PageName
) as mid_TotalCount
) as TotalCount,
(SELECT
sum(mid_GrandTotalCount.mid_hitcount) as hitcount
FROM
(SELECT
COUNT(NewLog_T.csUriStem) as mid_hitcount
FROM
NewLog_T,
Page_M
WHERE
SUBSTRING(NewLog_T.date,1,4) = '2005' AND
SUBSTRING(NewLog_T.date,6,2) = '08' AND
SUBSTRING(NewLog_T.date,9,2) = '29' AND
'http://www.testserver.com'+NewLog_T.csUriStem = Page_M.URL
GROUP BY
Page_M.PageName
) as mid_GrandTotalCount
) as GrandTotalCount
WHERE
SUBSTRING(NewLog_T.date,1,4) = '2005' AND
SUBSTRING(NewLog_T.date,6,2) = '08' AND
SUBSTRING(NewLog_T.date,9,2) = '29' AND
'http://www.testserver.com'+NewLog_T.csUriStem = Page_M.URL AND
NewLog_T.country = 'SG' ---------------------> to be set from QUERY A output
GROUP BY
Page_M.PageName,
TotalCount.hitcount,
GrandTotalCount.hitcount
ORDER BY
pagehitcount desc;
---------------------------------------------------------------

Thanks.
Aug 29 '05 #1
0 1976

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: rsarath | last post by:
Hello, I have the following setup and I would appreciate any help in improving the performance of the query. BigTable: Column1 (indexed)...
5
by: Gerald Khin | last post by:
I encountered a performance problem with UPDATE statement and foreign key constraints. There are two tables involved: A parent table A and a...
5
by: Scott | last post by:
I have a customer that had developed an Access97 application to track their business information. The application grew significantly and they used...
4
by: RamTurbo | last post by:
RamTurbo 2.6 Increase your computer speed by up to 200% Stop your computer from windows crashes Recover 100% of memory leaks Boost your PC...
3
by: Saradhi | last post by:
Hi All, Here I am facing a performance problem with the TreeView Node renaming. I am displaying a hierarchy Data in a treeview in my Windows C#...
6
by: Mike | last post by:
Lets just say my app is done HOO HOO. Now, I'm accessing the database via a web service and one thing i noticed that my app is running real slow....
36
by: mrby | last post by:
Hi, Does anyone know of any link which describes the (relative) performance of all kinds of C operations? e.g: how fast is "add" comparing with...
0
by: rxding | last post by:
Can Java Store Procedure increase performance Hello, Performance reason we need to move some of our code into database. Java Store Procedure...
8
by: NAdir | last post by:
Hi, thank you for your help. My VB.Net application contains a document that the user can refresh at any time. The refresh works fine and needs to...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.