Home » SQL & PL/SQL » SQL & PL/SQL » History Tables Search Criteria (windows)
History Tables Search Criteria [message #640166] Thu, 23 July 2015 04:23 Go to next message
oraranjangmailcom
Messages: 67
Registered: April 2010
Member
Hi Friends,

Please help to advise an approach on below scenario

Table "T1" (columns as C1 & indexed) has 2million records and it has 10 history tables of same structure/data volumes i.e., T2, T3, T4, ... T11
For each record in T1.C1, I've to search the not null record starting from T2, T3, T4 & ... if I found something at t2 itself then I can stop there itself else continue still table T10.

As these tables are history tables(even tough column C1 is indexed) and are of 2millions records each, don't want to join all the tables in a single query.

Help to tune the search.


Re: History Tables Search Criteria [message #640170 is a reply to message #640166] Thu, 23 July 2015 04:42 Go to previous messageGo to next message
Michel Cadot
Messages: 68643
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Don't your table have primary keys?

Re: History Tables Search Criteria [message #640171 is a reply to message #640166] Thu, 23 July 2015 04:47 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
oraranjangmailcom wrote on Thu, 23 July 2015 14:53
it has 10 history tables of same structure/data volumes i.e., T2, T3, T4, ... T11


What is the business need to have 10 identical tables?

Quote:
and are of 2millions records each


2 million rows X 10 tables = 20 million rows, with proper indexes and constraints it is not a huge operation. Anyway, first answer the first question, why do you have 10 identical tables?
Re: History Tables Search Criteria [message #640182 is a reply to message #640166] Thu, 23 July 2015 07:31 Go to previous messageGo to next message
er.surana
Messages: 4
Registered: July 2015
Location: INDIA
Junior Member
Hey

if all the column name is same in all table
then use union clause with where column is null and insert into new table so u will get all null record into new table and then compare with hist table.

pls if it helpful little bit then pls reply.
Re: History Tables Search Criteria [message #640211 is a reply to message #640182] Thu, 23 July 2015 10:37 Go to previous messageGo to next message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
@er.surana,

I am interested to know. JOIN vs UNION of tables, how do you decide?
Re: History Tables Search Criteria [message #640285 is a reply to message #640211] Sun, 26 July 2015 22:59 Go to previous messageGo to next message
oraranjangmailcom
Messages: 67
Registered: April 2010
Member
ok, all the 10 tables are history tables with data based on different date range.
I am fine to choose join condition, but by any chance is there a way to avoid the use of all the tables i.e., use the second table only when the first join doesn't return any records & so on ....

Note: currently, due to environmental limitations ( partition is disabled) I cannot opt for partition tables.
Re: History Tables Search Criteria [message #640288 is a reply to message #640285] Sun, 26 July 2015 23:26 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
>ok, all the 10 tables are history tables with data based on different date range.

Consider learning & implementing THIRD NORMAL FORM.
any DATE is application data & should NEVER be part of any table_name or column_name.
Re: History Tables Search Criteria [message #640291 is a reply to message #640285] Mon, 27 July 2015 00:19 Go to previous message
Michel Cadot
Messages: 68643
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
oraranjangmailcom wrote on Mon, 27 July 2015 05:59

...
I am fine to choose join condition, but by any chance is there a way to avoid the use of all the tables i.e., use the second table only when the first join doesn't return any records & so on ....
...


Already answered, use UNION ALL.

oraranjangmailcom wrote on Mon, 27 July 2015 05:59

...
Note: currently, due to environmental limitations ( partition is disabled) I cannot opt for partition tables.


Search for PARTITIONED VIEW.

Previous Topic: ORA-01732: data manipulation operation not legal on this view
Next Topic: Split column to rows in Oracle Sql
Goto Forum:
  


Current Time: Tue Apr 23 08:24:29 CDT 2024