From: Rafael Kitover <rkitover@cpan.org> Date: Tue, 15 May 2012 12:02:48 +0000 (-0400) Subject: add more docs on software_limit resultset attr X-Git-Tag: v0.08197~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9c510ba5d0481e77302d8689b4ae5cb63548b200;p=dbsrgits%2FDBIx-Class.git add more docs on software_limit resultset attr Add a paragraph to Storage/DBI/Sybase/ASE and a section under SEARCHING to Cookbook. --- diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index 014ff38..c91208c 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -440,6 +440,35 @@ etc.), but this may change in the future. See also L<SQL::Abstract/Literal SQL with placeholders and bind values (subqueries)>. +=head2 Software Limits + +When your RDBMS does not have a working SQL limit mechanism (e.g. Sybase ASE) +and L<GenericSubQ|SQL::Abstract::Limit/GenericSubQ> is either too slow or does +not work at all, you can try the +L<software_limit|DBIx::Class::ResultSet/software_limit> +L<DBIx::Class::ResultSet> attribute, which skips over records to simulate limits +in the Perl layer. + +For example: + + my $paged_rs = $rs->search({}, { + rows => 25, + page => 3, + order_by => [ 'me.last_name' ], + software_limit => 1, + }); + +You can set it as a default for your schema by placing the following in your +C<Schema.pm>: + + __PACKAGE__->default_resultset_attributes({ software_limit => 1 }); + +B<WARNING:> If you are dealing with large resultsets and your L<DBI> or +ODBC/ADO driver does not have proper cursor support (i.e. it loads the whole +resultset into memory) then this feature will be extremely slow and use huge +amounts of memory at best, and may cause your process to run out of memory and +cause instability on your server at worst, beware! + =head1 JOINS AND PREFETCHING =head2 Using joins and prefetch diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm b/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm index f7121e1..8d1419f 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm @@ -1068,6 +1068,18 @@ for information on changing the setting on the server side. See L</connect_call_datetime_setup> to setup date formats for L<DBIx::Class::InflateColumn::DateTime>. +=head1 LIMITED QUERIES + +Because ASE does not have a good way to limit results in SQL that works for all +types of queries, the limit dialect is set to +L<GenericSubQ|SQL::Abstract::Limit/GenericSubQ>. + +Fortunately, ASE and L<DBD::Sybase> support cursors properly, so when +L<GenericSubQ|SQL::Abstract::Limit/GenericSubQ> is too slow you can use +the L<software_limit|DBIx::Class::ResultSet/software_limit> +L<DBIx::Class::ResultSet> attribute to simulate limited queries by skipping over +records. + =head1 TEXT/IMAGE COLUMNS L<DBD::Sybase> compiled with FreeTDS will B<NOT> allow you to insert or update