Friday, August 15, 2014

Re: Cake 2.5.1 Extremely Slow With MSSQL?

Hi Dakota,

Thanks for clearing that up! I haven't looked at the source for CakePHP 3 yet so I didn't actually see how they implemented it. I should do more research next time as I don't want to mislead anybody...


On Fri, Aug 15, 2014 at 3:32 AM, Dakota <waltherlalk@gmail.com> wrote:
Hi Alan,

The Query object does not use SQL cursors, but rather buffers the results locally (In PHP land) and builds lists from that.

However, CakePHP 3.0 does rely on obtaining the row count (With PDOStatement::rowCount), which return -1 with PDO::CURSOR_FWDONLY (http://technet.microsoft.com/en-us/library/ff628154(v=sql.105).aspx)


On Thursday, 14 August 2014 20:00:52 UTC+2, Alan Read wrote:
I think the reasoning to use scroll was for future reasons....in CakePHP 3 they are introducing a new ORM layer (http://book.cakephp.org/3.0/en/appendices/orm-migration.html) and a Query Object. I believe they are going to implement the Query Object with methods like last, first, previous, next etc. With a scrollable cursor those operations are mapped one to one and should be pretty fast:

  • SCROLL: It specifies that all fetch options (FIRST, LAST, PRIOR, NEXT, RELATIVE, ABSOLUTE) are available. If SCROLL is not specified in an ISO DECLARE CURSOR, NEXT is the only fetch option supported. SCROLL cannot be specified if FAST_FORWARD is also specified.

If the cursor is set to FWDONLY, then the only operation available would be next. In my case, with cursor set to SCROLL a simple find query was taking 18 seconds to complete...since the majority of the time I just forward loop through a result set, losing first, last, previous etc is not that big of an issue.




On Thu, Aug 14, 2014 at 11:31 AM, Jordan Hopfner <nicke...@gmail.com> wrote:
In the PHP manual it states:

PDO::CURSOR_FWDONLY (integer)
Create a PDOStatement object with a forward-only cursor. This is the default cursor choice, as it is the fastest and most common data access pattern in PHP.
So I don't think it's a bad idea, but I don't know the reasoning the reasoning for using SCROLL over FWDONLY.

On Thursday, August 14, 2014 6:38:47 AM UTC-6, ravag...@gmail.com wrote:
I'm not sure if this is really a good idea.
See:
http://stackoverflow.com/questions/1155211/what-is-pdo-scrollable-cursor

But if you want this find its way into the core, then you can help the core team to get in there.

Help yourself by either:
a) Create an issue explaining everything on GitHub https://github.com/cakephp/cakephp/issues/new
b) Fork the code, change it, prove that it really solves the problem without breaking anything else and create a Pull Request https://github.com/cakephp/cakephp/

Thanks
Marc

Am Mittwoch, 13. August 2014 16:07:26 UTC+2 schrieb Jordan Hopfner:
Thanks Alan, appreciate the help. The project has been put on hold for now but I'll definitely try this change when I go to use SQL Server again. It would be great if the core team would make these changes to Cake :)

On Friday, August 8, 2014 10:30:20 PM UTC-6, Alan Read wrote:
Changing the line:

772) $prepareOptions += array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL);

to

772) $prepareOptions += array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY);

in the _execute function inside of Sqlserver.php solved this issue for me

On Wednesday, May 28, 2014 5:19:09 PM UTC-4, Jordan Hopfner wrote:
Hey guys,

I'm using the latest version of Cake (2.5.1) and am having a problem with extremely slow connections to a MSSQL server. A controller action that only has one simple select statement is taking an upwards of 50 seconds to complete. I don't think it's the select statement itself, I have a created an empty page that connects to MSSQL via PDO and executes the exact same statement and the result is instantaneous, so this leads me to believe it's a problem with the MSSQL data source packaged with Cake. If it was a driver or connection issue I would assume it would happen on the test page as well. Any ideas? I'm on PHP 5.3.x and am connecting to SQL Server 2008 R2.

Jordan

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to a topic in the Google Groups "CakePHP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/2Vqixc1UGCw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cake-php+u...@googlegroups.com.
To post to this group, send email to cake...@googlegroups.com.

Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.



--
Alan Read

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to a topic in the Google Groups "CakePHP" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cake-php/2Vqixc1UGCw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.



--
Alan Read

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: