OracleTimestampBuffer performance problem in vw7.4.1 ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

OracleTimestampBuffer performance problem in vw7.4.1 ?

Mark Plas

Hi,

 

I’ve encountered a problem with the OracleTimestampBuffer class in vw7.4.1. When I perform a query that contains a condition on a date column on oracle, and the query uses bind variables to supply the parameters, the query execution seems to block for about 2 seconds before I get a result.

 

Running the same query in VW7.2.1 doesn’t block the image. VW7.2.1 doesn’t have the OracleTimestampBuffer class.

 

When I change the references to OracleTimestampBuffer with OracleBuffer in vw7.4.1 and run the query again, I get the results instantaneous.

 

So far, I’ve noticed this problem with one specific query. When I add more conditions to the query it sometimes suddenly does run quickly.

The problem also only shows up on databases with a lot of data in the tables.

 

Has anybody encountered something like this ?

 

Thanks,

Mark

Reply | Threaded
Open this post in threaded view
|

Re: OracleTimestampBuffer performance problem in vw7.4.1 ?

Jan Lukeš
I have quite similar performance problem when running application in vw741
(the same application is running in vw74 and has no performace problems)

oracle tuning advisor says that there are some problems with type conversion
in sent sql and therefore indexes can't be used

only difference in the sql is:
{10 Jan 07 15:47:40}     OracleTimestampBuffer>>allocDescriptorForTimestamp:
    0 = OCIDescriptorAlloc( henv =31A66C8, timestampPointer  = 14A8D68, type  = OCI_DTYPE_TIMESTAMP xtramem_sz = 0, usrmempp = 0)

which is not present, when tracing sql in vw74


the main point is that Oracle is refusing to use index for timestamp/date column
    (means full scan on quite a large table)

there are some chages in OracleEXDI 7.4 -> 7.4.1 concerning timestamps
    but I can hardly understand/correct it on this level
        neither on the level of OCI calls

regards
Jan

Mark Plas napsal(a):

Hi,

 

I’ve encountered a problem with the OracleTimestampBuffer class in vw7.4.1. When I perform a query that contains a condition on a date column on oracle, and the query uses bind variables to supply the parameters, the query execution seems to block for about 2 seconds before I get a result.

 

Running the same query in VW7.2.1 doesn’t block the image. VW7.2.1 doesn’t have the OracleTimestampBuffer class.

 

When I change the references to OracleTimestampBuffer with OracleBuffer in vw7.4.1 and run the query again, I get the results instantaneous.

 

So far, I’ve noticed this problem with one specific query. When I add more conditions to the query it sometimes suddenly does run quickly.

The problem also only shows up on databases with a lot of data in the tables.

 

Has anybody encountered something like this ?

 

Thanks,

Mark


Reply | Threaded
Open this post in threaded view
|

RE: OracleTimestampBuffer performance problem in vw7.4.1 ?

Wallen, David
In reply to this post by Mark Plas

This issue doesn’t sound familiar.

 

-          what is the query you’re actually using, and

-          what is the column type, and

-          are you binding an instance of Date, or is it a Timestamp?

 

I think Dates will proceed as usual, but Timestamps will receive their own new dedicated timestamp buffer, supported by Oracle. So I would be surprised if you are using a Date bind object (but this is just a guess).

 

It is odd that Oracle doesn’t support Timestamp indexes. When the details are in, we might need to document this.

 

- Dave W


From: Mark Plas [mailto:[hidden email]]
Sent: Thursday, January 18, 2007 3:13 AM
To: vwnc-list
Subject: OracleTimestampBuffer performance problem in vw7.4.1 ?

 

Hi,

 

I’ve encountered a problem with the OracleTimestampBuffer class in vw7.4.1. When I perform a query that contains a condition on a date column on oracle, and the query uses bind variables to supply the parameters, the query execution seems to block for about 2 seconds before I get a result.

 

Running the same query in VW7.2.1 doesn’t block the image. VW7.2.1 doesn’t have the OracleTimestampBuffer class.

 

When I change the references to OracleTimestampBuffer with OracleBuffer in vw7.4.1 and run the query again, I get the results instantaneous.

 

So far, I’ve noticed this problem with one specific query. When I add more conditions to the query it sometimes suddenly does run quickly.

The problem also only shows up on databases with a lot of data in the tables.

 

Has anybody encountered something like this ?

 

Thanks,

Mark

Reply | Threaded
Open this post in threaded view
|

RE: OracleTimestampBuffer performance problem in vw7.4.1 ?

Mark Plas
In reply to this post by Mark Plas

Hi David,

 

The query is generated by Lens and looks like this:

 

SELECT *

FROM

            psi.psitxblock psitxblock1,

            psi.psitransmission psitransmission1,

            psi.psitxlink psitxlink1,

            psi.WOnRepeatLink WOnRepeatLink1,

            psi.psischedule psischedule1

WHERE

((((((((psitxblock1.txb_id_tx=psitransmission1.oid) AND

(psitransmission1.tx_id_txlink=psitxlink1.oid(+))) AND

(psitransmission1.tx_id_repeatLink=WOnRepeatLink1.oid(+))) AND

(psitransmission1.tx_id_schedule=psischedule1.oid)) AND

(psischedule1.sch_isactive=:p1)) AND

(psischedule1.sch_id_channel=:p2)) AND

(psitxblock1.txb_txdate=:p3)) AND

(psitxblock1.txb_id_group  IS NULL ))

 

When I replace the :p1 … :p3 variables with the real values the query returns results immediately. When the variables are

bound, it takes around two seconds before I get an answer in vw7.4.1. ‘:p3’ is the one that contains a Date.

 

The column type in Oracle is ‘Date’.

 

I’m binding an instance of Date. But, when I trace through the code, Lens converts the Date to a Timestamp. You can see this in the Date>>oracleConversion method:

 

oracleConversion

 

                        ^#Timestamp

 

 

And, on LensDatabaseContext there is the method #initializeBasicTypes that says:

 

addBasicType: (LensEncodedType new

                                    memberClass: Date;

                                    name: #Date;

                                    fieldType: (self typeNamed: #Timestamp);

                                    encodeSelector: #asTimestamp;

                                    decodeSelector: #asDate).

 

Which is also used to convert Date to Timestamp. I wonder why this conversion to Timestamps is necessary. I know that in Oracle a Date column can also contain Time information so perhaps this is the reason.

 

As a workaround I’ve overridden the method OracleSession>>timestampBufferClass so that it always returns OracleBuffer instead of the OracleTimestampBuffer, but I’m not sure what the consequences of this are.

I’ve ran all our tests and everything seems to work fine.

 

From your mail it seems that the OracleTimestampBuffer is needed for Timestamp objects. Would this mean that I can change the Date>>oracleConversion and LensDatabaseContext>>initializeBasicTypes so that they don’t convert Dates to Timestamp ?

 

Thanks,

Mark


From: Wallen, David [mailto:[hidden email]]
Sent: donderdag 18 januari 2007 20:33
To: Mark Plas; vwnc-list
Subject: RE: OracleTimestampBuffer performance problem in vw7.4.1 ?

 

This issue doesn’t sound familiar.

 

-          what is the query you’re actually using, and

-          what is the column type, and

-          are you binding an instance of Date, or is it a Timestamp?

 

I think Dates will proceed as usual, but Timestamps will receive their own new dedicated timestamp buffer, supported by Oracle. So I would be surprised if you are using a Date bind object (but this is just a guess).

 

It is odd that Oracle doesn’t support Timestamp indexes. When the details are in, we might need to document this.

 

- Dave W


From: Mark Plas [mailto:[hidden email]]
Sent: Thursday, January 18, 2007 3:13 AM
To: vwnc-list
Subject: OracleTimestampBuffer performance problem in vw7.4.1 ?

 

Hi,

 

I’ve encountered a problem with the OracleTimestampBuffer class in vw7.4.1. When I perform a query that contains a condition on a date column on oracle, and the query uses bind variables to supply the parameters, the query execution seems to block for about 2 seconds before I get a result.

 

Running the same query in VW7.2.1 doesn’t block the image. VW7.2.1 doesn’t have the OracleTimestampBuffer class.

 

When I change the references to OracleTimestampBuffer with OracleBuffer in vw7.4.1 and run the query again, I get the results instantaneous.

 

So far, I’ve noticed this problem with one specific query. When I add more conditions to the query it sometimes suddenly does run quickly.

The problem also only shows up on databases with a lot of data in the tables.

 

Has anybody encountered something like this ?

 

Thanks,

Mark

Reply | Threaded
Open this post in threaded view
|

Re: OracleTimestampBuffer performance problem in vw7.4.1 ?

Jan Lukeš
In reply to this post by Wallen, David
Hi David,

here are some more details on what I have

DLL for table and index creation:
    CREATE TABLE "MYTABLE"
        ("ID" NUMBER(10) NOT NULL,
        "COLUMN_TIMESTAMP" DATE,
        "COLUMN1" VARCHAR2(1000),
       .....);
    ALTER TABLE "MYTABLE"
        ADD PRIMARY KEY(ID);
    CREATE INDEX "MYTABLE_TIMESTAMP"
        ON "MYTABLE"  ("COLUMN_TIMESTAMP");

part of dataModelSpec:
                #(#{Lens.LensStructureVariable}
                        #name: 'column_timestamp'
                        #setValueType: #Timestamp
                        #fieldType: #Timestamp
                        #column:
                        #(#{Oracle7TableColumn}
                            #name: 'COLUMN_TIMESTAMP'
                            #dataType: 'date' )
                        #generatesAccessor: true
                        #generatesMutator: true
                        #privateIsMapped: true )

query:
    <resource: #query>
    | _qo |
    _qo := LensQuery new.
    _qo description: 'ownQuery'.
    _qo arrayContainerNames: #((#myTableDM #myTableDM) ).
    _qo answerBlockSource: ''.
    _qo selectWhere: [:myTableDM | myTableDM column_timestamp >=  self min_date].
    _qo selectBlockSource: 'myTableDM column_timestamp >=  self min_date'.
    _qo orderBy: [:myTableDM | myTableDM column_timestamp descending   ].
    _qo orderByBlockSource: 'myTableDM column_timestamp descending   '.
    _qo groupByBlockSource: ''.
    _qo useStreaming: true.
    _qo mode: #own.
    ^_qo
min_date
    ^(Date today subtractDays: 7) asTimestamp

tracing sql:
{10 Jan 07 15:46:55}     OracleSession>>prepareExternal
    0 = OCIStmtPrepare( hstmt =39A7924, herr =39976FC, SQL = SELECT SCHEMA.MYTABLE.ID,SCHEMA.MYTABLE.COLUMN_TIMESTAMP,...
FROM SCHEMA.MYTABLE WHERE (SCHEMA.MYTABLE.COLUMN_TIMESTAMP>=:p1) ORDER BY SCHEMA.MYTABLE.COLUMN_TIMESTAMP DESC , length  = 455, syntax = OCI_NTV_SYNTAX,  mode = OCI_DEFAULT)


Oracle tuning advisor says: (translated)
    predicate "MYTABLE.COLUMN_TIMESTAMP">=:B1 which is used ... in plan
    contains implicit conversion of data type in indexed column "COLUMN_TIMESTAMP".
    This implicit conversion of data type prevent optimizer from choosing indexes in table "MYTABLE"

regards
Jan

Wallen, David napsal(a):

This issue doesn’t sound familiar.

 

-          what is the query you’re actually using, and

-          what is the column type, and

-          are you binding an instance of Date, or is it a Timestamp?

 

I think Dates will proceed as usual, but Timestamps will receive their own new dedicated timestamp buffer, supported by Oracle. So I would be surprised if you are using a Date bind object (but this is just a guess).

 

It is odd that Oracle doesn’t support Timestamp indexes. When the details are in, we might need to document this.

 

- Dave W


From: Mark Plas [[hidden email]]
Sent: Thursday, January 18, 2007 3:13 AM
To: vwnc-list
Subject: OracleTimestampBuffer performance problem in vw7.4.1 ?

 

Hi,

 

I’ve encountered a problem with the OracleTimestampBuffer class in vw7.4.1. When I perform a query that contains a condition on a date column on oracle, and the query uses bind variables to supply the parameters, the query execution seems to block for about 2 seconds before I get a result.

 

Running the same query in VW7.2.1 doesn’t block the image. VW7.2.1 doesn’t have the OracleTimestampBuffer class.

 

When I change the references to OracleTimestampBuffer with OracleBuffer in vw7.4.1 and run the query again, I get the results instantaneous.

 

So far, I’ve noticed this problem with one specific query. When I add more conditions to the query it sometimes suddenly does run quickly.

The problem also only shows up on databases with a lot of data in the tables.

 

Has anybody encountered something like this ?

 

Thanks,

Mark


Reply | Threaded
Open this post in threaded view
|

RE: OracleTimestampBuffer performance problem in vw7.4.1 ?

Wallen, David
In reply to this post by Mark Plas

Mark and Jan,

 

Thanks both for the very detailed information. Evidently, Oracle doesn’t like comparing values between its special Timestamp and Date column types. Perhaps in the future, Oracle will coerce the bound object to the same type as held by the column. But maybe not. I’ll file an AR to examine this issue. What follows is some detailed blathering that should not be of much interest to others, but here goes.

 

VisualWorks has always converted Date and Time instances to a Timestamp instance before submission to the server, since Timestamp closely matches what an Oracle Date column holds. Recently, we embraced the higher precision Oracle Timestamp type to hold vw Timestamp objects.

 

The names are confusing. Here is how the mapping used to work:

VW Date, Time converted to VW Timestamp.

VW Timestamp -> Oracle Date (7 bytes holding date and time information) buffer type.

 

Then Oracle introduced its own higher resolution Timestamp type. We moved to the new type to avoid loss of precision (Timestamp milliseconds). Now it goes like this:

VW Date, Time converted to VW Timestamp.

VW Timestamp -> Oracle Timestamp (more resolution) buffer type.

 

Mark’s workaround, to override the >>timestampBufferClass method, looks okay for the short term. As for changing the Lens code to steer away from Timestamp conversion, I think this is on the idealized right track. I like the idea of mapping Date and Time to the usual Oracle Date type (which holds both), and mapping Timestamp alone to the new Oracle Timestamp type. But Timestamp already has so much baggage in existing code, maybe it is best left alone.

 

Ideally, Oracle would be more gracious about guessing our intent, and use the index as intended. A scheme that steals Mark’s idea might be to use a shared boolean, UseTimestampBuffer, so >>timestampBufferClass returns the default buffer class (new style or old style) for Timestamp instances. In addition, we could introduce a trivial subclass of Timestamp, OracleTimestamp class, which always uses the new buffer. So, images with no old code could set the flag #true. And those with legacy code could set the flag #false, and still have the ability to use OracleTimestamp instances where they want to take advantage of the new Oracle type.

 

Anyway, I’ll file the AR on Monday to look into this further. Thanks for your efforts.

 

- Dave W


From: Mark Plas [mailto:[hidden email]]
Sent: Friday, January 19, 2007 12:32 AM
To: Wallen, David; vwnc-list
Subject: RE: OracleTimestampBuffer performance problem in vw7.4.1 ?

 

Hi David,

 

The query is generated by Lens and looks like this:

 

SELECT *

FROM

            psi.psitxblock psitxblock1,

            psi.psitransmission psitransmission1,

            psi.psitxlink psitxlink1,

            psi.WOnRepeatLink WOnRepeatLink1,

            psi.psischedule psischedule1

WHERE

((((((((psitxblock1.txb_id_tx=psitransmission1.oid) AND

(psitransmission1.tx_id_txlink=psitxlink1.oid(+))) AND

(psitransmission1.tx_id_repeatLink=WOnRepeatLink1.oid(+))) AND

(psitransmission1.tx_id_schedule=psischedule1.oid)) AND

(psischedule1.sch_isactive=:p1)) AND

(psischedule1.sch_id_channel=:p2)) AND

(psitxblock1.txb_txdate=:p3)) AND

(psitxblock1.txb_id_group  IS NULL ))

 

When I replace the :p1 … :p3 variables with the real values the query returns results immediately. When the variables are

bound, it takes around two seconds before I get an answer in vw7.4.1. ‘:p3’ is the one that contains a Date.

 

The column type in Oracle is ‘Date’.

 

I’m binding an instance of Date. But, when I trace through the code, Lens converts the Date to a Timestamp. You can see this in the Date>>oracleConversion method:

 

oracleConversion

 

                        ^#Timestamp

 

 

And, on LensDatabaseContext there is the method #initializeBasicTypes that says:

 

addBasicType: (LensEncodedType new

                                    memberClass: Date;

                                    name: #Date;

                                    fieldType: (self typeNamed: #Timestamp);

                                    encodeSelector: #asTimestamp;

                                    decodeSelector: #asDate).

 

Which is also used to convert Date to Timestamp. I wonder why this conversion to Timestamps is necessary. I know that in Oracle a Date column can also contain Time information so perhaps this is the reason.

 

As a workaround I’ve overridden the method OracleSession>>timestampBufferClass so that it always returns OracleBuffer instead of the OracleTimestampBuffer, but I’m not sure what the consequences of this are.

I’ve ran all our tests and everything seems to work fine.

 

From your mail it seems that the OracleTimestampBuffer is needed for Timestamp objects. Would this mean that I can change the Date>>oracleConversion and LensDatabaseContext>>initializeBasicTypes so that they don’t convert Dates to Timestamp ?

 

Thanks,

Mark


From: Wallen, David [mailto:[hidden email]]
Sent: donderdag 18 januari 2007 20:33
To: Mark Plas; vwnc-list
Subject: RE: OracleTimestampBuffer performance problem in vw7.4.1 ?

 

This issue doesn’t sound familiar.

 

-          what is the query you’re actually using, and

-          what is the column type, and

-          are you binding an instance of Date, or is it a Timestamp?

 

I think Dates will proceed as usual, but Timestamps will receive their own new dedicated timestamp buffer, supported by Oracle. So I would be surprised if you are using a Date bind object (but this is just a guess).

 

It is odd that Oracle doesn’t support Timestamp indexes. When the details are in, we might need to document this.

 

- Dave W


From: Mark Plas [mailto:[hidden email]]
Sent: Thursday, January 18, 2007 3:13 AM
To: vwnc-list
Subject: OracleTimestampBuffer performance problem in vw7.4.1 ?

 

Hi,

 

I’ve encountered a problem with the OracleTimestampBuffer class in vw7.4.1. When I perform a query that contains a condition on a date column on oracle, and the query uses bind variables to supply the parameters, the query execution seems to block for about 2 seconds before I get a result.

 

Running the same query in VW7.2.1 doesn’t block the image. VW7.2.1 doesn’t have the OracleTimestampBuffer class.

 

When I change the references to OracleTimestampBuffer with OracleBuffer in vw7.4.1 and run the query again, I get the results instantaneous.

 

So far, I’ve noticed this problem with one specific query. When I add more conditions to the query it sometimes suddenly does run quickly.

The problem also only shows up on databases with a lot of data in the tables.

 

Has anybody encountered something like this ?

 

Thanks,

Mark

Reply | Threaded
Open this post in threaded view
|

RE: OracleTimestampBuffer performance problem in vw7.4.1 ?

Wallen, David
In reply to this post by Mark Plas

Thanks again for this info. The following AR has been created for reference.

 

AR# 51752 OracleTimestamp may be slowing down Lens queries.

 

- Dave W

 


From: Wallen, David
Sent: Saturday, January 20, 2007 12:43 PM
To: Mark Plas; vwnc-list
Subject: RE: OracleTimestampBuffer performance problem in vw7.4.1 ?

 

Mark and Jan,

 

Thanks both for the very detailed information. Evidently, Oracle doesn’t like comparing values between its special Timestamp and Date column types. Perhaps in the future, Oracle will coerce the bound object to the same type as held by the column. But maybe not. I’ll file an AR to examine this issue. What follows is some detailed blathering that should not be of much interest to others, but here goes.

 

VisualWorks has always converted Date and Time instances to a Timestamp instance before submission to the server, since Timestamp closely matches what an Oracle Date column holds. Recently, we embraced the higher precision Oracle Timestamp type to hold vw Timestamp objects.

 

The names are confusing. Here is how the mapping used to work:

VW Date, Time converted to VW Timestamp.

VW Timestamp -> Oracle Date (7 bytes holding date and time information) buffer type.

 

Then Oracle introduced its own higher resolution Timestamp type. We moved to the new type to avoid loss of precision (Timestamp milliseconds). Now it goes like this:

VW Date, Time converted to VW Timestamp.

VW Timestamp -> Oracle Timestamp (more resolution) buffer type.

 

Mark’s workaround, to override the >>timestampBufferClass method, looks okay for the short term. As for changing the Lens code to steer away from Timestamp conversion, I think this is on the idealized right track. I like the idea of mapping Date and Time to the usual Oracle Date type (which holds both), and mapping Timestamp alone to the new Oracle Timestamp type. But Timestamp already has so much baggage in existing code, maybe it is best left alone.

 

Ideally, Oracle would be more gracious about guessing our intent, and use the index as intended. A scheme that steals Mark’s idea might be to use a shared boolean, UseTimestampBuffer, so >>timestampBufferClass returns the default buffer class (new style or old style) for Timestamp instances. In addition, we could introduce a trivial subclass of Timestamp, OracleTimestamp class, which always uses the new buffer. So, images with no old code could set the flag #true. And those with legacy code could set the flag #false, and still have the ability to use OracleTimestamp instances where they want to take advantage of the new Oracle type.

 

Anyway, I’ll file the AR on Monday to look into this further. Thanks for your efforts.

 

- Dave W


From: Mark Plas [mailto:[hidden email]]
Sent: Friday, January 19, 2007 12:32 AM
To: Wallen, David; vwnc-list
Subject: RE: OracleTimestampBuffer performance problem in vw7.4.1 ?

 

Hi David,

 

The query is generated by Lens and looks like this:

 

SELECT *

FROM

            psi.psitxblock psitxblock1,

            psi.psitransmission psitransmission1,

            psi.psitxlink psitxlink1,

            psi.WOnRepeatLink WOnRepeatLink1,

            psi.psischedule psischedule1

WHERE

((((((((psitxblock1.txb_id_tx=psitransmission1.oid) AND

(psitransmission1.tx_id_txlink=psitxlink1.oid(+))) AND

(psitransmission1.tx_id_repeatLink=WOnRepeatLink1.oid(+))) AND

(psitransmission1.tx_id_schedule=psischedule1.oid)) AND

(psischedule1.sch_isactive=:p1)) AND

(psischedule1.sch_id_channel=:p2)) AND

(psitxblock1.txb_txdate=:p3)) AND

(psitxblock1.txb_id_group  IS NULL ))

 

When I replace the :p1 … :p3 variables with the real values the query returns results immediately. When the variables are

bound, it takes around two seconds before I get an answer in vw7.4.1. ‘:p3’ is the one that contains a Date.

 

The column type in Oracle is ‘Date’.

 

I’m binding an instance of Date. But, when I trace through the code, Lens converts the Date to a Timestamp. You can see this in the Date>>oracleConversion method:

 

oracleConversion

 

                        ^#Timestamp

 

 

And, on LensDatabaseContext there is the method #initializeBasicTypes that says:

 

addBasicType: (LensEncodedType new

                                    memberClass: Date;

                                    name: #Date;

                                    fieldType: (self typeNamed: #Timestamp);

                                    encodeSelector: #asTimestamp;

                                    decodeSelector: #asDate).

 

Which is also used to convert Date to Timestamp. I wonder why this conversion to Timestamps is necessary. I know that in Oracle a Date column can also contain Time information so perhaps this is the reason.

 

As a workaround I’ve overridden the method OracleSession>>timestampBufferClass so that it always returns OracleBuffer instead of the OracleTimestampBuffer, but I’m not sure what the consequences of this are.

I’ve ran all our tests and everything seems to work fine.

 

From your mail it seems that the OracleTimestampBuffer is needed for Timestamp objects. Would this mean that I can change the Date>>oracleConversion and LensDatabaseContext>>initializeBasicTypes so that they don’t convert Dates to Timestamp ?

 

Thanks,

Mark


From: Wallen, David [mailto:[hidden email]]
Sent: donderdag 18 januari 2007 20:33
To: Mark Plas; vwnc-list
Subject: RE: OracleTimestampBuffer performance problem in vw7.4.1 ?

 

This issue doesn’t sound familiar.

 

-          what is the query you’re actually using, and

-          what is the column type, and

-          are you binding an instance of Date, or is it a Timestamp?

 

I think Dates will proceed as usual, but Timestamps will receive their own new dedicated timestamp buffer, supported by Oracle. So I would be surprised if you are using a Date bind object (but this is just a guess).

 

It is odd that Oracle doesn’t support Timestamp indexes. When the details are in, we might need to document this.

 

- Dave W


From: Mark Plas [mailto:[hidden email]]
Sent: Thursday, January 18, 2007 3:13 AM
To: vwnc-list
Subject: OracleTimestampBuffer performance problem in vw7.4.1 ?

 

Hi,

 

I’ve encountered a problem with the OracleTimestampBuffer class in vw7.4.1. When I perform a query that contains a condition on a date column on oracle, and the query uses bind variables to supply the parameters, the query execution seems to block for about 2 seconds before I get a result.

 

Running the same query in VW7.2.1 doesn’t block the image. VW7.2.1 doesn’t have the OracleTimestampBuffer class.

 

When I change the references to OracleTimestampBuffer with OracleBuffer in vw7.4.1 and run the query again, I get the results instantaneous.

 

So far, I’ve noticed this problem with one specific query. When I add more conditions to the query it sometimes suddenly does run quickly.

The problem also only shows up on databases with a lot of data in the tables.

 

Has anybody encountered something like this ?

 

Thanks,

Mark

Reply | Threaded
Open this post in threaded view
|

RE: OracleTimestampBuffer performance problem in vw7.4.1 ?

Mark Plas
In reply to this post by Mark Plas

Thanks David.

 


From: Wallen, David [mailto:[hidden email]]
Sent: dinsdag 23 januari 2007 21:59
To: Mark Plas; vwnc-list; Jan Lukeš
Subject: RE: OracleTimestampBuffer performance problem in vw7.4.1 ?

 

Thanks again for this info. The following AR has been created for reference.

 

AR# 51752 OracleTimestamp may be slowing down Lens queries.

 

- Dave W

 


From: Wallen, David
Sent: Saturday, January 20, 2007 12:43 PM
To: Mark Plas; vwnc-list
Subject: RE: OracleTimestampBuffer performance problem in vw7.4.1 ?

 

Mark and Jan,

 

Thanks both for the very detailed information. Evidently, Oracle doesn’t like comparing values between its special Timestamp and Date column types. Perhaps in the future, Oracle will coerce the bound object to the same type as held by the column. But maybe not. I’ll file an AR to examine this issue. What follows is some detailed blathering that should not be of much interest to others, but here goes.

 

VisualWorks has always converted Date and Time instances to a Timestamp instance before submission to the server, since Timestamp closely matches what an Oracle Date column holds. Recently, we embraced the higher precision Oracle Timestamp type to hold vw Timestamp objects.

 

The names are confusing. Here is how the mapping used to work:

VW Date, Time converted to VW Timestamp.

VW Timestamp -> Oracle Date (7 bytes holding date and time information) buffer type.

 

Then Oracle introduced its own higher resolution Timestamp type. We moved to the new type to avoid loss of precision (Timestamp milliseconds). Now it goes like this:

VW Date, Time converted to VW Timestamp.

VW Timestamp -> Oracle Timestamp (more resolution) buffer type.

 

Mark’s workaround, to override the >>timestampBufferClass method, looks okay for the short term. As for changing the Lens code to steer away from Timestamp conversion, I think this is on the idealized right track. I like the idea of mapping Date and Time to the usual Oracle Date type (which holds both), and mapping Timestamp alone to the new Oracle Timestamp type. But Timestamp already has so much baggage in existing code, maybe it is best left alone.

 

Ideally, Oracle would be more gracious about guessing our intent, and use the index as intended. A scheme that steals Mark’s idea might be to use a shared boolean, UseTimestampBuffer, so >>timestampBufferClass returns the default buffer class (new style or old style) for Timestamp instances. In addition, we could introduce a trivial subclass of Timestamp, OracleTimestamp class, which always uses the new buffer. So, images with no old code could set the flag #true. And those with legacy code could set the flag #false, and still have the ability to use OracleTimestamp instances where they want to take advantage of the new Oracle type.

 

Anyway, I’ll file the AR on Monday to look into this further. Thanks for your efforts.

 

- Dave W


From: Mark Plas [mailto:[hidden email]]
Sent: Friday, January 19, 2007 12:32 AM
To: Wallen, David; vwnc-list
Subject: RE: OracleTimestampBuffer performance problem in vw7.4.1 ?

 

Hi David,

 

The query is generated by Lens and looks like this:

 

SELECT *

FROM

            psi.psitxblock psitxblock1,

            psi.psitransmission psitransmission1,

            psi.psitxlink psitxlink1,

            psi.WOnRepeatLink WOnRepeatLink1,

            psi.psischedule psischedule1

WHERE

((((((((psitxblock1.txb_id_tx=psitransmission1.oid) AND

(psitransmission1.tx_id_txlink=psitxlink1.oid(+))) AND

(psitransmission1.tx_id_repeatLink=WOnRepeatLink1.oid(+))) AND

(psitransmission1.tx_id_schedule=psischedule1.oid)) AND

(psischedule1.sch_isactive=:p1)) AND

(psischedule1.sch_id_channel=:p2)) AND

(psitxblock1.txb_txdate=:p3)) AND

(psitxblock1.txb_id_group  IS NULL ))

 

When I replace the :p1 … :p3 variables with the real values the query returns results immediately. When the variables are

bound, it takes around two seconds before I get an answer in vw7.4.1. ‘:p3’ is the one that contains a Date.

 

The column type in Oracle is ‘Date’.

 

I’m binding an instance of Date. But, when I trace through the code, Lens converts the Date to a Timestamp. You can see this in the Date>>oracleConversion method:

 

oracleConversion

 

                        ^#Timestamp

 

 

And, on LensDatabaseContext there is the method #initializeBasicTypes that says:

 

addBasicType: (LensEncodedType new

                                    memberClass: Date;

                                    name: #Date;

                                    fieldType: (self typeNamed: #Timestamp);

                                    encodeSelector: #asTimestamp;

                                    decodeSelector: #asDate).

 

Which is also used to convert Date to Timestamp. I wonder why this conversion to Timestamps is necessary. I know that in Oracle a Date column can also contain Time information so perhaps this is the reason.

 

As a workaround I’ve overridden the method OracleSession>>timestampBufferClass so that it always returns OracleBuffer instead of the OracleTimestampBuffer, but I’m not sure what the consequences of this are.

I’ve ran all our tests and everything seems to work fine.

 

From your mail it seems that the OracleTimestampBuffer is needed for Timestamp objects. Would this mean that I can change the Date>>oracleConversion and LensDatabaseContext>>initializeBasicTypes so that they don’t convert Dates to Timestamp ?

 

Thanks,

Mark


From: Wallen, David [mailto:[hidden email]]
Sent: donderdag 18 januari 2007 20:33
To: Mark Plas; vwnc-list
Subject: RE: OracleTimestampBuffer performance problem in vw7.4.1 ?

 

This issue doesn’t sound familiar.

 

-          what is the query you’re actually using, and

-          what is the column type, and

-          are you binding an instance of Date, or is it a Timestamp?

 

I think Dates will proceed as usual, but Timestamps will receive their own new dedicated timestamp buffer, supported by Oracle. So I would be surprised if you are using a Date bind object (but this is just a guess).

 

It is odd that Oracle doesn’t support Timestamp indexes. When the details are in, we might need to document this.

 

- Dave W


From: Mark Plas [mailto:[hidden email]]
Sent: Thursday, January 18, 2007 3:13 AM
To: vwnc-list
Subject: OracleTimestampBuffer performance problem in vw7.4.1 ?

 

Hi,

 

I’ve encountered a problem with the OracleTimestampBuffer class in vw7.4.1. When I perform a query that contains a condition on a date column on oracle, and the query uses bind variables to supply the parameters, the query execution seems to block for about 2 seconds before I get a result.

 

Running the same query in VW7.2.1 doesn’t block the image. VW7.2.1 doesn’t have the OracleTimestampBuffer class.

 

When I change the references to OracleTimestampBuffer with OracleBuffer in vw7.4.1 and run the query again, I get the results instantaneous.

 

So far, I’ve noticed this problem with one specific query. When I add more conditions to the query it sometimes suddenly does run quickly.

The problem also only shows up on databases with a lot of data in the tables.

 

Has anybody encountered something like this ?

 

Thanks,

Mark