Quantcast
Channel: SCN : Discussion List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 6412

Gaps in a sequence when using a row table.

$
0
0

Hi,

 

I was the process of writing a blog for SCN when I stumbled across something that might be a bug.  When inserting into a row table from a subquery, I get gaps in the sequence I'm calling.  This does not happen doing the same process when inserting to a column table.  I'm using HANA1.0r70.  You can try it yourself with the following SQL.

 

DROP SCHEMA SQI CASCADE;

CREATE SCHEMA SQI;

SET SCHEMA SQI;

CREATE COLUMN TABLE CTAB1 (ID INTEGER PRIMARY KEY, COL1 NVARCHAR(128));

CREATE SEQUENCE SEQCOL;

CREATE ROW TABLE RTAB1 (ID INTEGER PRIMARY KEY, COL1 NVARCHAR(128));

CREATE SEQUENCE SEQROW;

INSERT INTO CTAB1

(

  SELECT TOP 1000

  SEQCOL.NEXTVAL,

  TO_NCHAR(RAND())

  FROM

  OBJECTS

  CROSS JOIN

  OBJECTS);

INSERT INTO RTAB1

(

  SELECT TOP 1000

  SEQROW.NEXTVAL,

  TO_NCHAR(RAND())

  FROM

  OBJECTS

  CROSS JOIN

  OBJECTS);

 

 

SELECT

  COUNT(*),

  MIN(ID),

  MAX(ID)

FROM

  CTAB1;

 

SELECT

  COUNT(*),

  MIN(ID),

  MAX(ID)

FROM

  RTAB1;

 

On my system the result from CTAB1 shows the row count as 1000, minimum ID as 1 and the maximum ID as 1000.  The result from RTAB1 should be the same but returns with the row count as 1000, minimum ID as 1 and the maximum ID as 37,750.

 

A SELECT * FROM RTAB1 shows the sequence starts off OK.  After ID 125 there is a jump to 5,376.  This also increments correctly for 125 rows before leaping to 5,500.  After every 125 rows, the sequence skips a large number of places. 

 

It's worth mentioning that this only happens when cross joining OBJECTS and using the RAND function (as far as I know).  Everything works as expected when the subquery is pulling rows from real tables.  It also works find when cross joining OBJECTS but only inserting the ID column using the sequence.  I'd be extremely interested if anyone can shed any light on what is happening here.


Viewing all articles
Browse latest Browse all 6412

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>