Current location: Hot Scripts Forums » Programming Languages » ASP » is it a good idea to run 23 search expressions?


is it a good idea to run 23 search expressions?

Reply
  #1 (permalink)  
Old 03-21-04, 01:19 PM
lordmerlin lordmerlin is offline
Newbie Coder
 
Join Date: Jul 2003
Location: South Africa
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Post is it a good idea to run 23 search expressions?

Ok, this is quite a complicated one.

I got a table, which takes user comments, and ratings, when a user clicks a rating, it's being recorded, with the date.

I want to display these ratings as follows:

The total for the week:
total for the month:
total for the year:
total for rating 1
total for rating 2
total for rating 3
total for rating 4
total for rating 5

total for rating 1 for the week
total for rating 2 for the week
total for rating 3 for the week
total for rating 4 for the week
total for rating 5 for the week

total for rating 1 for the month
total for rating 2 for the month
total for rating 3 for the month
total for rating 4 for the month
total for rating 5 for the month

total for rating 1 for the year
total for rating 2 for the year
total for rating 3 for the year
total for rating 4 for the year
total for rating 5 for the year

Below is one of my select statements, showing the yearly total
Set yRS=Server.Createobject("ADODB.RECORDSET")
ySQL="SELECT COUNT(*) AS amount FROM rightclick_responses WHERE (datetime_added >= '" & YoldDate & "') AND (client_id = '" & Session
("companyid") & "') AND (questionaire_id = '2')"


This works, but I don't think 23 search expressions is a good idea, expesially not for performance.

Can anyone recommend something better?
Reply With Quote
  #2 (permalink)  
Old 03-24-04, 04:05 PM
chemical chemical is offline
New Member
 
Join Date: Mar 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
1. Put all your SQL code inside a stored procedure. This way you only do a single hit to the database. Inside the stored procedure, create 23 variables, set their values through our SQL statements, and then return 1 row with 23 columns.

2. Make sure you index your table. You'll should probably create a clustered index on "companyid" and non-clustered indexes on "datetime_added" and "questionaire_id". Set your fill-factor correctly and re-build you indexes often.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SEO Expert Available nakulgoyal Job Offers & Assistance 2 08-14-04 12:38 PM
Simple search script niceguyonline Script Requests 3 03-07-04 11:09 PM
Declared Functions skipper23 PHP 4 12-17-03 10:06 AM
index page not showing up skipper23 PHP 3 12-15-03 01:10 PM
Looking for a good search script Loon Script Requests 1 07-03-03 11:48 PM


All times are GMT -5. The time now is 04:17 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.