Skip to content

Commit

Permalink
add more docs on software_limit resultset attr
Browse files Browse the repository at this point in the history
Add a paragraph to Storage/DBI/Sybase/ASE and a section under SEARCHING
to Cookbook.
  • Loading branch information
rkitover committed May 15, 2012
1 parent 9ab122a commit 9c510ba
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lib/DBIx/Class/Manual/Cookbook.pod
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm
Expand Up @@ -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
Expand Down

0 comments on commit 9c510ba

Please sign in to comment.