search->first, find, and single
DBIx::Class 简单地读取一条数据的时候有三种方法。
一是用 ->search( { author_id => 1 } )->first;
二是用 ->find( { author_id => 1 } );
三是用 ->single( { author_id => 1 } );
我用 Data::Compare 比较过。三者的数据是一样的。
但是原理上来说,最下面的是最快的。因为没有创建一个 Cursor.
http://search.cpan.org/~jrobinson/DBIx-Class-0.07001/lib/DBIx/Class/ResultSet.pm#single
一是用 ->search( { author_id => 1 } )->first;
二是用 ->find( { author_id => 1 } );
三是用 ->single( { author_id => 1 } );
我用 Data::Compare 比较过。三者的数据是一样的。
但是原理上来说,最下面的是最快的。因为没有创建一个 Cursor.
http://search.cpan.org/~jrobinson/DBIx-Class-0.07001/lib/DBIx/Class/ResultSet.pm#single
Labels: DBIx-Class
2 Comments:
I found a list of free PERL books available online for download which might be useful for the readers.
Top 4 Perl Books for free download.
mm, these books are somehow outdated.
I will recommend the newest Perl Best Pratices and Perl Cookbook 4.
:)
Post a Comment
Links to this post:
Create a Link
<< Home