Home > Default > DECODE versus creating a separate table and doing a join

DECODE versus creating a separate table and doing a join

October 11Hits:0
Advertisement
Hi,
This question is on what Oracle does internally for the decode function on a field value.
I have two options:
(i) use the decode function to do a quick and dirty SQL statement
(ii) create a table that has the results what that decode will do, and do a join with that table.
I tend to shy away from using decode in SQL, since I hate the idea of putting business information into an SQL statement, and also I thought using functions of any kind slowed SQL down, and that one should limit it as much as possible "standard" SQL.
Is the gain from using a separate table real, illusory or is it worse than using DECODE?
Thanks,
Regards,
Srini

Answers

Thanks for all the responses. I talked with my DBA and decided to go with the table option rather than the decode option. Here are the reasons.
1. Mixing business information in your program is never a good idea (this of course goes beyond just SQL/Oracle, applying to all programming). This is related to what you mentioned, Kevin. I don't want to restrict the names in my tables simply because I have hard-coded something into my program. Over a period of time, this would result in a minefield of decodes.
2. I forgot to mention - the decode would be in my 'where' clause - that is why I had the question on speed. It seemed to me that if the system had to translate each field, it could obviously not take advantage of any indexing the column had, and would be slower. Cartesian products are bad enough, we don't want a computation to be tacked on to it as well, right?
Regards,
Srini

Read other 7 answers

Tags:

Related Articles

  • DECODE versus creating a separate table and doing a joinOctober 11

    Hi, This question is on what Oracle does internally for the decode function on a field value. I have two options: (i) use the decode function to do a quick and dirty SQL statement (ii) create a table that has the results what that decode will do, and

  • Creating 2 separate tables with thin bordersNovember 30

    I am trying to create 2 separate tables that have a thin border and a space between the 2 tables. I am new to CSS but have used Dreamweaver since its infancy, Check this link for what I am referring to http://www.sprucebodylab.com/index.php ThanksMan

  • Creating a new table next to an existing oneNovember 30

    I have attached the table I created...(I'm a beginner....forgive me for being simplistic in design). I want to create a separate table for "Friday" right next to the existing table. How do i get the new table to align to the right of the existin

  • Repeat to create multi-column tableNovember 30

    I'm trying to use a spry:repeat directive to create a two-column table. What I would like to have generated as a result of the repeat is something like the following: <table> <tr> <td>row[0] data</td> <td>row[1] data</td&g

  • Creating 2 separate buttons instead of table cellNovember 30

    Hi, I wonder how can I create a custom table cell like in contacts applications where instead of one cell you see 2 separate buttons on the same row? In my case I need to create 2 buttons instead of single row in the state of editing. Thanks for help

  • Partitions versus separate tablesNovember 30

    I have a general question.... I have a table which represents a container, of which there are two types, Logical and Physical. Physical containers are actually constructs, where as logical containers are sort of made up, they don't exist in the real

  • Error while creating Global temp tableOctober 11

    Hi, I am very new to PL/SQL so please excuse my question. I have the below query . I have to get a count between the source table and various target tables. I am creating a global temp table to store the counts. I am getting the below error for my fo

  • How to build a table with predifined? Like Huffman decoding, there are 34 predefined tables?October 11

    I am trying to use Labview for mp3 huffman decoding. there are 34 predefined tables for lookup purpose. I tried build array control, but it is so hard to assign value with size of 16. What is the better way to create predefined array? And how to do l

  • How can I sum up raws? the sum function seems to work for columns only and right now I have to create a separate formula for each rawOctober 11

    How can I sum up raws? the Sum function seems to work only on columns. Right now I have to create a separate formula for each rawHi dah, "Thanks, but can I do one formula for all present and future raws? as raws are being added, I have to do the sum

  • Creating a master table and using it to populate other tables.November 30

    Hi everyone. I am a novice at using Numbers and I need some direction. I am looking to create a master table with information for our summer camp. This table will include vital information such as name, address, etc. along with cabin assignments, tui

Copyright (C) 2019 wisumpire.com, All Rights Reserved. webmaster#wisumpire.com 14 q. 0.499 s.