Which is faster? - نوشته شده در (651 Views)
Senior Member
muzishun
مطلب: 1079
1079
I'm working on an application using Snitz, and I'm trying to figure out the best way to do part of it.
Users will be able to select from their profile which categories and forums are displayed to them on the main page. The same will go for evens (already added the calendar MOD). What I'm wondering is if it would be faster to:
(a) store the information in a Session variable or cookie, then loop through the list of cats and forums they want to display and verify that events fall under these, or
(b) hit the database with a large query with a bunch of "WHERE cat = x OR cat = y OR cat = z...." tacked on, or
(c) something I haven't thought of yet (if there's a simpler way to do this, I'm all ears)

Hope that's a little clearer than mud. Looking back through it I'm not sure I explained it well, but let me know if there's something I need to clarify more.<
Bill Parrott
Senior Web Programmer, University of Kansas
Co-Owner and Code Monkey, Eternal Second Designs (www.eternalsecond.com)
Personal Website (www.chimericdream.com)
 پیش‌فرض مرتب‌سازی برای تاریخ DESC به معنی جدیدترین است  
 تعداد در صفحه 
نوشته شده در
Support Moderator
Shaggy
مطلب: 6780
6780
I'd go with modifying the existing query to select the exact forums the user wants to see, something along the lines of:

SELECT [FIELDS] FROM [TABLES] WHERE [CONDITIONS] AND CAT_ID IN (SELECT CAT_ID FROM [YOUR_NEW_TABLE] WHERE MEMBER_ID="&MemberID&")
Depending on the database you're using, you may have to pull that nested query out and run it sperately.
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
نوشته شده در
Senior Member
muzishun
مطلب: 1079
1079
Thanks. I'm using MySQL, so the queries should run fairly fast. I'm also looking into the possibility of this being on a dedicated server (in the future, if this grows like we're hoping it will), so that will help with some performance issues.
I had a feeling that might be the simplest way to do it, but wanted to double check it with people here, since I'm still relatively new in comparison.<
Bill Parrott
Senior Web Programmer, University of Kansas
Co-Owner and Code Monkey, Eternal Second Designs (www.eternalsecond.com)
Personal Website (www.chimericdream.com)
نوشته شده در
Support Moderator
Shaggy
مطلب: 6780
6780
Ay, trouble with doing it with session varaibles is that they'd have to be repopulated every time the members started a new session, requiring an additional db hit each time.
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
نوشته شده در
Senior Member
muzishun
مطلب: 1079
1079
That's true. Looks like I'll end up going the route of nested query. Thanks for the help.<
Bill Parrott
Senior Web Programmer, University of Kansas
Co-Owner and Code Monkey, Eternal Second Designs (www.eternalsecond.com)
Personal Website (www.chimericdream.com)
نوشته شده در
Support Moderator
Shaggy
مطلب: 6780
6780
You're welcome, Bill smile
<
Search is your friend “I was having a mildly paranoid day, mostly due to the
fact that the mad priest lady from over the river had
taken to nailing weasels to my front door again.”
 
شما باید یک متن وارد کنید