Personal computing discussed

Moderators: renee, SecretSquirrel, just brew it!

 
Turkina
Gerbil Elite
Topic Author
Posts: 607
Joined: Mon Apr 21, 2003 10:02 pm
Location: Philly

Wed Oct 19, 2005 10:47 am

Thanks guys, it does seem like the two query idea is the best approach...
And I will look into MSDE...might as well since this is just in the exploratory phase. Data import is a big issue, but then again, it doesnt work out smoothly with Access either (importing excel spreadsheets into access definately doesnt work as well as it should)
Thanks again,

~Turkina
if coding_ethics = 0 then goto microsoft
 
just brew it!
Administrator
Posts: 54500
Joined: Tue Aug 20, 2002 10:51 pm
Location: Somewhere, having a beer

Wed Oct 19, 2005 10:56 am

thegleek wrote:
yeah well, i still probably would never use an IF or CASE statement within a sql query... it's just not in my coding ethics to do so...

So you've got something against writing efficient code?

The reason SQL constructs like case exist in the first place -- and are allowed within a select -- is to allow you to explicitly tell the DBMS what you are trying to accomplish. This allows the DBMS to optimize the query for efficient execution. Simply pulling all of the data and sorting through it using a procedural language can be horrendously inefficient in comparison.

This kind of optimization becomes even more important in multi-tier applications where the DBMS is running on a machine other than the one issuing the query, since it can reduce the amount of data sent over the network by orders of magnitude.
Nostalgia isn't what it used to be.
 
Flying Fox
Gerbil God
Posts: 25690
Joined: Mon May 24, 2004 2:19 am
Contact:

Thu Oct 20, 2005 2:02 pm

The classic case for using the CASE construct is to reduce the number of sub-queries used in statements. Don't know about other databases, but during our performance analysis on Oracle those little sub-queries look innocent enough, but then combined in the larger expression they become full table scans on the mini-results, and is seriously taking up the shared memory. Quite inefficient and unscalable. :o
 
morphine
TR Staff
Posts: 11600
Joined: Fri Dec 27, 2002 8:51 pm
Location: Portugal (that's next to Spain)

Thu Oct 20, 2005 2:08 pm

As with everything, YMMV :)

I've used IF statements (similar to CASE) in a couple of places exactly to avoid sub-queries and they were a great help, however, they were simple cases to so I guess it's a very nice tool to be used with caution.
 
Kevin
Administrator
Posts: 6581
Joined: Thu Dec 27, 2001 7:00 pm
Location: Minneapolis, MN
Contact:

Fri Oct 21, 2005 11:14 am

I've split off the completely off-topic posts that were in this thread to the Back Porch. Let's the keep the tech threads on topic.

Kevin
 
danny e.
Maximum Gerbil
Posts: 4444
Joined: Thu Apr 25, 2002 3:09 pm
Location: Indonesia/Nebraska/Wisconsin

Sat Oct 22, 2005 1:51 am

thegleek wrote:
Flying Fox wrote:
Edit: gleek, I think CASE is SQL-92, it can be quite new for even experienced DB developer to use. Last company I worked we just couldn't use it since bloody Oracle 8i did not have it yet. The performance of the CASE statement is quite phenominal once we switched to Oracle 9 and compared old and new queries.


yeah well, i still probably would never use an IF or CASE statement
within a sql query... it's just not in my coding ethics to do so...


i am thinking about trying that line at work.
"hey mr. bossman, i realize it would be much more efficient to do it your way.. but thats just not in my coding ethics."

heh. that would be hilarious. .. at least for a minute till i got fired.
:D
You don't have to feel safe to feel unafraid.

Who is online

Users browsing this forum: No registered users and 1 guest
GZIP: On