Unix Technical Forum

Numbering of promary keys in sorted order

This is a discussion on Numbering of promary keys in sorted order within the Informix forums, part of the Database Server Software category; --> Hello, all I need help to get an ascending serial number (INT8) and a primary key in sorted order ...


Go Back   Unix Technical Forum > Database Server Software > Informix

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-20-2008, 04:20 PM
Richard Kofler
 
Posts: n/a
Default Numbering of promary keys in sorted order

Hello, all

I need help to get an ascending serial number (INT8)
and a primary key in sorted order into a helper table.

As long as intermediate tables are not to be fragmented,
a solution along these lines did work:

SELECT PK from source INTO TEMP helper ORDER by 1;
Insert INTO raw_helper

CREATE raw_helper table
with serial and column for the PK of source
as a RAW table to make it faster.

INSERT INTO raw_helper .... SELECT from temp table.

But as soon as the temp table is fragmented and the
RAW table has FRAGMENT BY EXPRESSION
there is no more ascending order in the PK copies, if selected
ORDER BY serial_column.

I therefore believe, that the sort order with small amounts of rows
was a side effekt, one can not relay on.

I posted this very same subject a few days ago and the
question I _should_ ask is rather:

ow to simulate the forbidden
INSERT INTO .... SELECT FROM
and ORDER BY at the same time.

All help appreciated.

dic_K

--
Richard Kofler
SOLID STATE EDV
Dienstleistungen GmbH
Vienna/Austria/Europe
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-20-2008, 04:21 PM
Richard Kofler
 
Posts: n/a
Default Re: Numbering of primary keys in sorted order

Richard Kofler schrieb:
> Hello, all
>
> I need help to get an ascending serial number (INT8)
> and a primary key in sorted order into a helper table.
>
> As long as intermediate tables are not to be fragmented,
> a solution along these lines did work:
>
> SELECT PK from source INTO TEMP helper ORDER by 1;
> Insert INTO raw_helper
>
> CREATE raw_helper table
> with serial and column for the PK of source
> as a RAW table to make it faster.
>
> INSERT INTO raw_helper .... SELECT from temp table.
>
> But as soon as the temp table is fragmented and the
> RAW table has FRAGMENT BY EXPRESSION
> there is no more ascending order in the PK copies, if selected
> ORDER BY serial_column.
>
> I therefore believe, that the sort order with small amounts of rows
> was a side effekt, one can not relay on.
>
> I posted this very same subject a few days ago and the
> question I _should_ ask is rather:
>
> ow to simulate the forbidden
> INSERT INTO .... SELECT FROM
> and ORDER BY at the same time.
>
> All help appreciated.
>
> dic_K
>


just to keep this thread going:
For now I have written a stored procedure, and this
works fine.

In a FOREACH ... WITH HOLD ... INTO I select the values of the
primary keys in sorted order into a variable, using ORDER BY.

Then I insert into the helper table, which has a serial8 column
and a column of a suitable type to hold the values of the PKs.

I then can calculate aequidistant values of the serial column,
along with min and max, select the values of the column holding
the copies of the source table's PKs at these values of the
serial column, and am able to return lines of the type
need after FRAGMENT BY EXPRESSION, like so:
((x_id >= 1) AND (x_id < 10056000)) IN dbs_P096
, ((x_id >= 10056000) AND (x_id < 43133900)) IN dbs_P097
and so on.
Using that lines, I can distribute a compound index evenly
among the fragments, i.e. every fragment holds the same
number of index entries.

I have been able to verify, that there is a considerable
speed up coming along with the now parallel index scans,
whenever the result set is biggish, and all columns from
the projection list are contained in the index.

I also can see that there ist no I/O on datapages.


But I still have not found a way to do this preparation
of low and high bounds for the rule lines in one SQL-statement.

dic_k
--
Richard Kofler
SOLID STATE EDV
Dienstleistungen GmbH
Vienna/Austria/Europe
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:06 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com