Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Database Server Software > DB2

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-26-2008, 06:19 PM
Todd Huish
 
Posts: n/a
Default php-odbc and dynamic vs forward only cursors

I have noticed something disturbing when retrieving datasets over a
relatively slow line (multiple T1). I am looking at about 25 seconds to
retrieve 500 rows via a php-odbc link. This same select from the cli is
for all intents practicaly instantaneous. After much research I discovered
that PHP by default uses a dynamic cursor type which can be quite a bit
slower than a forward only cursor. BTW I have been searching forward
only/read only/static cursor as all the same thing, if this is incorrect
someone please disabuse me of the notion. I found some posts on how to
change the php-odbc driver to use forward only cursors. After happily
hacking the php source and recompiling my 500 row result set went from 25
seconds to < 1 second. Elated by this test I recompiled on my main server
and had the programmers run some tests. The problem now is that they use
the odbc_num_rows() function -a lot- and it broke this for them. I found
plenty of documentation on why this is. My main question is, is there
another way to get the odbc driver to return a static cursor. I tried "for
read only" on the end of my sql statements and it appeared to make no
difference. Idealy I would like to use forward only cursors whenever
possible and dynamic ones when row counts are required. I can think of
ways that they can get around using row counts, they are only using them
for a positive/negative on wether a select statement returned any rows,
but until that code can all change I need a different solution.

--
Todd Huish
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-26-2008, 06:20 PM
Dan Scott
 
Posts: n/a
Default Re: php-odbc and dynamic vs forward only cursors

Wow, there are a lot of questions crammed in there, unfortunately
without much useful data about your environment. I'll try to help where
I can.

First: what are you running on? DB2 version (with FixPak if any),
operating system and version, PHP version. What's your database client
environment and your server environment?

Are you using ODBC connectivity through something like unixODBC or did
you compile PHP using the --with-ibm-db2 configure flag to use native
CLI support?

Finally, there's a really interesting (and old) user comment on the PHP
documentation at http://ca.php.net/manual/en/function.odbc-connect.php
that sounds incredibly similar to your situation -- basically, using the
optional cursor type parameter on your odbc_connect() call to specify
SQL_CUR_USE_ODBC increased the performance of their application from
taking up to 10 seconds for retrieving 100 rows down to a fraction of a
second.

More comments throughout...

Todd Huish wrote:
> I have noticed something disturbing when retrieving datasets over a
> relatively slow line (multiple T1). I am looking at about 25 seconds to
> retrieve 500 rows via a php-odbc link. This same select from the cli is
> for all intents practicaly instantaneous. After much research I
> discovered that PHP by default uses a dynamic cursor type which can be
> quite a bit slower than a forward only cursor.


Yes, basically--PHP requests a dynamic cursor, and DB2 downgrades it to
a keyset-driven cursor. A good resource for some of the guts of PHP /
DB2 interaction is Clara Liu's "Application Development Experiences with
PHP and DB2 Universal Database Version 8" --
http://www-106.ibm.com/developerwork...u/0301liu.html
Clara states that to force PHP to open a read-only cursor you just need
to append FOR READ ONLY to your SELECT statements.

> BTW I have been
> searching forward only/read only/static cursor as all the same thing,
> if this is incorrect someone please disabuse me of the notion.


The best description of the differences between cursors can be found in
the topic "Cursors in CLI applications" at
http://publib.boulder.ibm.com/infoce...d/c0007645.htm
Quick differentiation: static and forward only cursors are both
read-only, but static cursors are scrollable (backwards and forwards),
whereas forward only are, well, forward only.

> I found
> some posts on how to change the php-odbc driver to use forward only
> cursors. After happily hacking the php source and recompiling my 500
> row result set went from 25 seconds to < 1 second. Elated by this test
> I recompiled on my main server and had the programmers run some tests.
> The problem now is that they use the odbc_num_rows() function -a lot-
> and it broke this for them.


Ah, change the source and you've pretty much lost out on any chance of
getting further help from anyone other than the people that posted the
hacks. Did you try appending "FOR READ ONLY" to your statements before
changing the source?

> I found plenty of documentation on why this
> is. My main question is, is there another way to get the odbc driver to
> return a static cursor. I tried "for read only" on the end of my sql
> statements and it appeared to make no difference.


Weird. That should make a big difference. I can see that "FOR READ ONLY"
does the right thing on my Red Hat ES 3.0 Update 2 / DB2 "Stinger" beta
/ PHP 5.0RC2 compiled --with-ibm-db2 system.

> Idealy I would like
> to use forward only cursors whenever possible and dynamic ones when row
> counts are required. I can think of ways that they can get around using
> row counts, they are only using them for a positive/negative on wether
> a select statement returned any rows, but until that code can all
> change I need a different solution.


Clara's article describes a better way of finding out whether a SELECT
statement returned rows or not -- basically, check the return value of
odbc_result() on the first row that you try to fetch. Using
odbc_num_rows() with DB2 returns the number of rows affected by INSERT,
UPDATE, or DELETE statements, and has nothing to do with SELECT
statements, so it shouldn't even have worked in the way that you
describe before you changed the PHP source.

Dan
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-26-2008, 06:20 PM
Todd Huish
 
Posts: n/a
Default Re: php-odbc and dynamic vs forward only cursors

On Thu, 10 Jun 2004 09:52:42 -0400, Dan Scott <dan.scott@ca.ibm.com> wrote:

> Wow, there are a lot of questions crammed in there, unfortunately
> without much useful data about your environment. I'll try to help where
> I can.
>
> First: what are you running on? DB2 version (with FixPak if any),
> operating system and version, PHP version. What's your database client
> environment and your server environment?
>

I apologize for the lack of info. It's one of those things where the
problem has been plaguing me for days and has rendered me slightly
insensible.
I am running DB2 UDB 8.1.5 on a RHEL 3 platform for the server and a MDK
10 client with 8.1.5 as well.

> Are you using ODBC connectivity through something like unixODBC or did
> you compile PHP using the --with-ibm-db2 configure flag to use native
> CLI support?


I have PHP 4.3.6 which is compiled with the --with-ibm-db2 flag.

>
> Finally, there's a really interesting (and old) user comment on the PHP
> documentation at http://ca.php.net/manual/en/function.odbc-connect.php
> that sounds incredibly similar to your situation -- basically, using the
> optional cursor type parameter on your odbc_connect() call to specify
> SQL_CUR_USE_ODBC increased the performance of their application from
> taking up to 10 seconds for retrieving 100 rows down to a fraction of a
> second.


I read that post and tried adding SQL_CUR_USE_ODBC to my connect string
but it didn't fly. I had hopes too because that is the -exact- problem I
am having. DB2 gives me the following error which I will have to track
down some more.

Warning: odbc_connect(): SQL error: [IBM][CLI Driver] CLI0150E Driver not
capable. SQLSTATE=S1C00, SQL state S1C00 in SQLSetConnectOption in
/virtualhosts/test/www/db2_test.php on line 8

>
> More comments throughout...
>
> Todd Huish wrote:
>> I have noticed something disturbing when retrieving datasets over a
>> relatively slow line (multiple T1). I am looking at about 25 seconds
>> to retrieve 500 rows via a php-odbc link. This same select from the
>> cli is for all intents practicaly instantaneous. After much research I
>> discovered that PHP by default uses a dynamic cursor type which can be
>> quite a bit slower than a forward only cursor.

>
> Yes, basically--PHP requests a dynamic cursor, and DB2 downgrades it to
> a keyset-driven cursor. A good resource for some of the guts of PHP /
> DB2 interaction is Clara Liu's "Application Development Experiences with
> PHP and DB2 Universal Database Version 8" --
> http://www-106.ibm.com/developerwork...u/0301liu.html
> Clara states that to force PHP to open a read-only cursor you just need
> to append FOR READ ONLY to your SELECT statements.
>
>> BTW I have been searching forward only/read only/static cursor as all
>> the same thing, if this is incorrect someone please disabuse me of the
>> notion.

>
> The best description of the differences between cursors can be found in
> the topic "Cursors in CLI applications" at
> http://publib.boulder.ibm.com/infoce...d/c0007645.htm
> Quick differentiation: static and forward only cursors are both
> read-only, but static cursors are scrollable (backwards and forwards),
> whereas forward only are, well, forward only.
>
>> I found some posts on how to change the php-odbc driver to use forward
>> only cursors. After happily hacking the php source and recompiling my
>> 500 row result set went from 25 seconds to < 1 second. Elated by this
>> test I recompiled on my main server and had the programmers run some
>> tests. The problem now is that they use the odbc_num_rows() function
>> -a lot- and it broke this for them.

>
> Ah, change the source and you've pretty much lost out on any chance of
> getting further help from anyone other than the people that posted the
> hacks. Did you try appending "FOR READ ONLY" to your statements before
> changing the source?


Yeah, that is the very first thing I tried. This also, unfortunately, did
not work allthough everything I read says it should have. I'm not sure why
what I am doing is ignoring the "for read only" indicator. At this point
my php source is back to unhacked. I don't really like leaving it in that
state but I am quickly reaching the end of my rope and am willing to try
anything.

>
>> I found plenty of documentation on why this is. My main question is,
>> is there another way to get the odbc driver to return a static cursor.
>> I tried "for read only" on the end of my sql statements and it
>> appeared to make no difference.

>
> Weird. That should make a big difference. I can see that "FOR READ ONLY"
> does the right thing on my Red Hat ES 3.0 Update 2 / DB2 "Stinger" beta
> / PHP 5.0RC2 compiled --with-ibm-db2 system.


I'll have to try this some more. I have php5 installed I just don't use it
that much yet. At least this way I know -someone- has gotten this to work
so with that knowledge I can hopefuly forge ahead.

>
>> Idealy I would like to use forward only cursors whenever possible and
>> dynamic ones when row counts are required. I can think of ways that
>> they can get around using row counts, they are only using them for a
>> positive/negative on wether a select statement returned any rows, but
>> until that code can all change I need a different solution.

>
> Clara's article describes a better way of finding out whether a SELECT
> statement returned rows or not -- basically, check the return value of
> odbc_result() on the first row that you try to fetch. Using
> odbc_num_rows() with DB2 returns the number of rows affected by INSERT,
> UPDATE, or DELETE statements, and has nothing to do with SELECT
> statements, so it shouldn't even have worked in the way that you
> describe before you changed the PHP source.


I was unaware they were using num_rows in this fashion and had to have a
bit of a training email to the developers as to what that function is used
for. The problem is that they are very used to using this function to
determine if a select returned a result because we have all been using
mysql for years and that function works just fine. An education problem on
my part. Now of course trying to get all the code changed is a totally
different and joyous proposition.

>
> Dan



--
Todd Huish
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-26-2008, 06:22 PM
Dan Scott
 
Posts: n/a
Default Re: php-odbc and dynamic vs forward only cursors

Well, I'm afraid I don't have good news to report at this point. I
tested a remote client-server connection (two tiers: browser and Apache
w/ PHP running on client, DB2 on remote server) over an ADSL line and
consistently got 500 rows in about 18 seconds through PHP (writing to a
file, so browser rendering wasn't a factor) vs. 3 seconds for CLI -- but
running a local client-server connection was almost instantaneous. I've
made a few notes interspersed below, but it looks like there's a
bottleneck showing up specifically in the remote client scenario.

I'll try to dig a little further, but I wanted to let you know what I
had found so far.

Todd Huish wrote:
> On Thu, 10 Jun 2004 09:52:42 -0400, Dan Scott <dan.scott@ca.ibm.com> wrote:
>
>> Wow, there are a lot of questions crammed in there, unfortunately
>> without much useful data about your environment. I'll try to help
>> where I can.
>>
>> First: what are you running on? DB2 version (with FixPak if any),
>> operating system and version, PHP version. What's your database
>> client environment and your server environment?
>>

> I apologize for the lack of info. It's one of those things where the
> problem has been plaguing me for days and has rendered me slightly
> insensible.
> I am running DB2 UDB 8.1.5 on a RHEL 3 platform for the server and a
> MDK 10 client with 8.1.5 as well.
>
>> Are you using ODBC connectivity through something like unixODBC or
>> did you compile PHP using the --with-ibm-db2 configure flag to use
>> native CLI support?

>
>
> I have PHP 4.3.6 which is compiled with the --with-ibm-db2 flag.


PHP 5.0RC2 compiled --with-ibm-db2 here, although I tried running
with unixODBC instead and got exactly the same results of 18 seconds
for 500 rows.

>>
>> Finally, there's a really interesting (and old) user comment on the
>> PHP documentation at
>> http://ca.php.net/manual/en/function.odbc-connect.php that sounds
>> incredibly similar to your situation -- basically, using the optional
>> cursor type parameter on your odbc_connect() call to specify
>> SQL_CUR_USE_ODBC increased the performance of their application from
>> taking up to 10 seconds for retrieving 100 rows down to a fraction of
>> a second.

>
>
> I read that post and tried adding SQL_CUR_USE_ODBC to my connect string
> but it didn't fly. I had hopes too because that is the -exact- problem
> I am having. DB2 gives me the following error which I will have to
> track down some more.
>
> Warning: odbc_connect(): SQL error: [IBM][CLI Driver] CLI0150E Driver
> not capable. SQLSTATE=S1C00, SQL state S1C00 in SQLSetConnectOption in
> /virtualhosts/test/www/db2_test.php on line 8
>


I tried it as well, with exactly the same error. Another post I found
suggested that it only worked with unixODBC, so I gave that a shot, but
still got the same error.

>>
>> More comments throughout...
>>
>> Todd Huish wrote:
>>
>>> I have noticed something disturbing when retrieving datasets over a
>>> relatively slow line (multiple T1). I am looking at about 25 seconds
>>> to retrieve 500 rows via a php-odbc link. This same select from the
>>> cli is for all intents practicaly instantaneous. After much research
>>> I discovered that PHP by default uses a dynamic cursor type which
>>> can be quite a bit slower than a forward only cursor.

>>
>>
>> Yes, basically--PHP requests a dynamic cursor, and DB2 downgrades it
>> to a keyset-driven cursor. A good resource for some of the guts of
>> PHP / DB2 interaction is Clara Liu's "Application Development
>> Experiences with PHP and DB2 Universal Database Version 8" --
>> http://www-106.ibm.com/developerwork...u/0301liu.html
>>
>> Clara states that to force PHP to open a read-only cursor you just
>> need to append FOR READ ONLY to your SELECT statements.
>>
>>> BTW I have been searching forward only/read only/static cursor as
>>> all the same thing, if this is incorrect someone please disabuse me
>>> of the notion.

>>
>>
>> The best description of the differences between cursors can be found
>> in the topic "Cursors in CLI applications" at
>> http://publib.boulder.ibm.com/infoce...d/c0007645.htm
>> Quick differentiation: static and forward only cursors are both
>> read-only, but static cursors are scrollable (backwards and
>> forwards), whereas forward only are, well, forward only.
>>
>>> I found some posts on how to change the php-odbc driver to use
>>> forward only cursors. After happily hacking the php source and
>>> recompiling my 500 row result set went from 25 seconds to < 1
>>> second. Elated by this test I recompiled on my main server and had
>>> the programmers run some tests. The problem now is that they use
>>> the odbc_num_rows() function -a lot- and it broke this for them.

>>
>>
>> Ah, change the source and you've pretty much lost out on any chance
>> of getting further help from anyone other than the people that posted
>> the hacks. Did you try appending "FOR READ ONLY" to your statements
>> before changing the source?

>
>
> Yeah, that is the very first thing I tried. This also, unfortunately,
> did not work allthough everything I read says it should have. I'm not
> sure why what I am doing is ignoring the "for read only" indicator. At
> this point my php source is back to unhacked. I don't really like
> leaving it in that state but I am quickly reaching the end of my rope
> and am willing to try anything.


Understood. Is there any chance of running Apache/PHP on the same
machine as your DB2 server?

>>
>>> I found plenty of documentation on why this is. My main question
>>> is, is there another way to get the odbc driver to return a static
>>> cursor. I tried "for read only" on the end of my sql statements and
>>> it appeared to make no difference.

>>
>>
>> Weird. That should make a big difference. I can see that "FOR READ
>> ONLY" does the right thing on my Red Hat ES 3.0 Update 2 / DB2
>> "Stinger" beta / PHP 5.0RC2 compiled --with-ibm-db2 system.

>
>
> I'll have to try this some more. I have php5 installed I just don't use
> it that much yet. At least this way I know -someone- has gotten this to
> work so with that knowledge I can hopefuly forge ahead.
>
>>
>>> Idealy I would like to use forward only cursors whenever possible
>>> and dynamic ones when row counts are required. I can think of ways
>>> that they can get around using row counts, they are only using them
>>> for a positive/negative on wether a select statement returned any
>>> rows, but until that code can all change I need a different solution.

>>
>>
>> Clara's article describes a better way of finding out whether a
>> SELECT statement returned rows or not -- basically, check the return
>> value of odbc_result() on the first row that you try to fetch. Using
>> odbc_num_rows() with DB2 returns the number of rows affected by
>> INSERT, UPDATE, or DELETE statements, and has nothing to do with
>> SELECT statements, so it shouldn't even have worked in the way that
>> you describe before you changed the PHP source.

>
>
> I was unaware they were using num_rows in this fashion and had to have
> a bit of a training email to the developers as to what that function is
> used for. The problem is that they are very used to using this function
> to determine if a select returned a result because we have all been
> using mysql for years and that function works just fine. An education
> problem on my part. Now of course trying to get all the code changed is
> a totally different and joyous proposition.
>
>>
>> Dan

>
>
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-26-2008, 06:23 PM
Dan Scott
 
Posts: n/a
Default Re: php-odbc and dynamic vs forward only cursors

A further set of data: running the same 500-row SELECT tests over a
local 100MB LAN connection (latency: ~0.1ms) in the same two-tier
configuration gave me sub-second PHP results, so the network is clearly
a major factor. Windows client -> Windows server and Linux client ->
Windows server showed the same results.

Dan

Dan Scott wrote:
> Well, I'm afraid I don't have good news to report at this point. I
> tested a remote client-server connection (two tiers: browser and Apache
> w/ PHP running on client, DB2 on remote server) over an ADSL line and
> consistently got 500 rows in about 18 seconds through PHP (writing to a
> file, so browser rendering wasn't a factor) vs. 3 seconds for CLI -- but
> running a local client-server connection was almost instantaneous. I've
> made a few notes interspersed below, but it looks like there's a
> bottleneck showing up specifically in the remote client scenario.
>
> I'll try to dig a little further, but I wanted to let you know what I
> had found so far.
>
> Todd Huish wrote:
>
>> On Thu, 10 Jun 2004 09:52:42 -0400, Dan Scott <dan.scott@ca.ibm.com>
>> wrote:
>>
>>> Wow, there are a lot of questions crammed in there, unfortunately
>>> without much useful data about your environment. I'll try to help
>>> where I can.
>>>
>>> First: what are you running on? DB2 version (with FixPak if any),
>>> operating system and version, PHP version. What's your database
>>> client environment and your server environment?
>>>

>> I apologize for the lack of info. It's one of those things where the
>> problem has been plaguing me for days and has rendered me slightly
>> insensible.
>> I am running DB2 UDB 8.1.5 on a RHEL 3 platform for the server and a
>> MDK 10 client with 8.1.5 as well.
>>
>>> Are you using ODBC connectivity through something like unixODBC or
>>> did you compile PHP using the --with-ibm-db2 configure flag to use
>>> native CLI support?

>>
>>
>>
>> I have PHP 4.3.6 which is compiled with the --with-ibm-db2 flag.

>
>
> PHP 5.0RC2 compiled --with-ibm-db2 here, although I tried running
> with unixODBC instead and got exactly the same results of 18 seconds
> for 500 rows.
>
>>>
>>> Finally, there's a really interesting (and old) user comment on the
>>> PHP documentation at
>>> http://ca.php.net/manual/en/function.odbc-connect.php that sounds
>>> incredibly similar to your situation -- basically, using the
>>> optional cursor type parameter on your odbc_connect() call to
>>> specify SQL_CUR_USE_ODBC increased the performance of their
>>> application from taking up to 10 seconds for retrieving 100 rows
>>> down to a fraction of a second.

>>
>>
>>
>> I read that post and tried adding SQL_CUR_USE_ODBC to my connect
>> string but it didn't fly. I had hopes too because that is the -exact-
>> problem I am having. DB2 gives me the following error which I will
>> have to track down some more.
>>
>> Warning: odbc_connect(): SQL error: [IBM][CLI Driver] CLI0150E Driver
>> not capable. SQLSTATE=S1C00, SQL state S1C00 in SQLSetConnectOption
>> in /virtualhosts/test/www/db2_test.php on line 8
>>

>
> I tried it as well, with exactly the same error. Another post I found
> suggested that it only worked with unixODBC, so I gave that a shot, but
> still got the same error.
>
>>>
>>> More comments throughout...
>>>
>>> Todd Huish wrote:
>>>
>>>> I have noticed something disturbing when retrieving datasets over
>>>> a relatively slow line (multiple T1). I am looking at about 25
>>>> seconds to retrieve 500 rows via a php-odbc link. This same select
>>>> from the cli is for all intents practicaly instantaneous. After
>>>> much research I discovered that PHP by default uses a dynamic
>>>> cursor type which can be quite a bit slower than a forward only
>>>> cursor.
>>>
>>>
>>>
>>> Yes, basically--PHP requests a dynamic cursor, and DB2 downgrades it
>>> to a keyset-driven cursor. A good resource for some of the guts of
>>> PHP / DB2 interaction is Clara Liu's "Application Development
>>> Experiences with PHP and DB2 Universal Database Version 8" --
>>> http://www-106.ibm.com/developerwork...u/0301liu.html
>>>
>>> Clara states that to force PHP to open a read-only cursor you just
>>> need to append FOR READ ONLY to your SELECT statements.
>>>
>>>> BTW I have been searching forward only/read only/static cursor as
>>>> all the same thing, if this is incorrect someone please disabuse
>>>> me of the notion.
>>>
>>>
>>>
>>> The best description of the differences between cursors can be found
>>> in the topic "Cursors in CLI applications" at
>>> http://publib.boulder.ibm.com/infoce...d/c0007645.htm
>>> Quick differentiation: static and forward only cursors are both
>>> read-only, but static cursors are scrollable (backwards and
>>> forwards), whereas forward only are, well, forward only.
>>>
>>>> I found some posts on how to change the php-odbc driver to use
>>>> forward only cursors. After happily hacking the php source and
>>>> recompiling my 500 row result set went from 25 seconds to < 1
>>>> second. Elated by this test I recompiled on my main server and had
>>>> the programmers run some tests. The problem now is that they use
>>>> the odbc_num_rows() function -a lot- and it broke this for them.
>>>
>>>
>>>
>>> Ah, change the source and you've pretty much lost out on any chance
>>> of getting further help from anyone other than the people that
>>> posted the hacks. Did you try appending "FOR READ ONLY" to your
>>> statements before changing the source?

>>
>>
>>
>> Yeah, that is the very first thing I tried. This also, unfortunately,
>> did not work allthough everything I read says it should have. I'm not
>> sure why what I am doing is ignoring the "for read only" indicator.
>> At this point my php source is back to unhacked. I don't really like
>> leaving it in that state but I am quickly reaching the end of my rope
>> and am willing to try anything.

>
>
> Understood. Is there any chance of running Apache/PHP on the same
> machine as your DB2 server?
>
>>>
>>>> I found plenty of documentation on why this is. My main question
>>>> is, is there another way to get the odbc driver to return a static
>>>> cursor. I tried "for read only" on the end of my sql statements
>>>> and it appeared to make no difference.
>>>
>>>
>>>
>>> Weird. That should make a big difference. I can see that "FOR READ
>>> ONLY" does the right thing on my Red Hat ES 3.0 Update 2 / DB2
>>> "Stinger" beta / PHP 5.0RC2 compiled --with-ibm-db2 system.

>>
>>
>>
>> I'll have to try this some more. I have php5 installed I just don't
>> use it that much yet. At least this way I know -someone- has gotten
>> this to work so with that knowledge I can hopefuly forge ahead.
>>
>>>
>>>> Idealy I would like to use forward only cursors whenever possible
>>>> and dynamic ones when row counts are required. I can think of ways
>>>> that they can get around using row counts, they are only using
>>>> them for a positive/negative on wether a select statement returned
>>>> any rows, but until that code can all change I need a different
>>>> solution.
>>>
>>>
>>>
>>> Clara's article describes a better way of finding out whether a
>>> SELECT statement returned rows or not -- basically, check the return
>>> value of odbc_result() on the first row that you try to fetch.
>>> Using odbc_num_rows() with DB2 returns the number of rows affected
>>> by INSERT, UPDATE, or DELETE statements, and has nothing to do with
>>> SELECT statements, so it shouldn't even have worked in the way that
>>> you describe before you changed the PHP source.

>>
>>
>>
>> I was unaware they were using num_rows in this fashion and had to have
>> a bit of a training email to the developers as to what that function
>> is used for. The problem is that they are very used to using this
>> function to determine if a select returned a result because we have
>> all been using mysql for years and that function works just fine. An
>> education problem on my part. Now of course trying to get all the
>> code changed is a totally different and joyous proposition.
>>
>>>
>>> Dan

>>
>>
>>
>>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-26-2008, 06:23 PM
Todd Huish
 
Posts: n/a
Default Re: php-odbc and dynamic vs forward only cursors

On Mon, 14 Jun 2004 14:30:59 -0400, Dan Scott <dan.scott@ca.ibm.com> wrote:

> A further set of data: running the same 500-row SELECT tests over a
> local 100MB LAN connection (latency: ~0.1ms) in the same two-tier
> configuration gave me sub-second PHP results, so the network is clearly
> a major factor. Windows client -> Windows server and Linux client ->
> Windows server showed the same results.
>
> Dan
>


Yeah thats about the same thing I am showing. I would like to run the db2
server close to the webservers, and I do for the front end websites, but I
can't for the backend tools which are web based as well. They will
eventualy be using a locally replicated copy of the db but that is down
the road a couple months. I have re-educated the developers in the use of
the num_rows() function and after a weekend of fixing I think we are going
to be able to live without it and I should be able to change the php
driver to use the forward_only cursor. Live, learn, do, learn some more,
backtrack, re-do, eventualy come into the light...this is the life we live
:-)

--
Todd Huish
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 03:00 PM.


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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473