... | ... |
@@ -1,4 +1,6 @@ |
1 | 1 |
0.1706 |
2 |
+ - Added execute method's query option document |
|
3 |
+ You can get more performance. |
|
2 | 4 |
- DBIx::Custom::Query table and filters attribute method and |
3 | 5 |
filter method is DEPRECATED! |
4 | 6 |
because I think query object must have only the information |
... | ... |
@@ -2200,9 +2200,21 @@ You can check SQL or get statment handle. |
2200 | 2200 |
|
2201 | 2201 |
my $sql = $query->sql; |
2202 | 2202 |
my $sth = $query->sth; |
2203 |
+ my $columns = $query->columns; |
|
2204 |
+ |
|
2205 |
+If you want to execute SQL fast, you can do the following way. |
|
2206 |
+ |
|
2207 |
+ my $query; |
|
2208 |
+ foreach my $row (@$rows) { |
|
2209 |
+ $query ||= $dbi->insert($row, table => 'table1', query => 1); |
|
2210 |
+ $dbi->execute($query, $row, filter => {ab => sub { $_[0] * 2 }}); |
|
2211 |
+ } |
|
2212 |
+ |
|
2213 |
+Statement handle is reused and SQL parsing is finished, |
|
2214 |
+so you can get more performance than normal way. |
|
2203 | 2215 |
|
2204 | 2216 |
If you want to execute SQL as possible as fast and don't need filtering. |
2205 |
-You do the following way. |
|
2217 |
+You can do the following way. |
|
2206 | 2218 |
|
2207 | 2219 |
my $query; |
2208 | 2220 |
my $sth; |
... | ... |
@@ -3467,6 +3467,26 @@ $rows = $result->all; |
3467 | 3467 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}]); |
3468 | 3468 |
|
3469 | 3469 |
test 'high perfomance way'; |
3470 |
+$dbi->execute($DROP_TABLE->{0}); |
|
3471 |
+$dbi->execute("create table table1 (ab, bc, ik, hi, ui, pq, dc);"); |
|
3472 |
+$rows = [ |
|
3473 |
+ {ab => 1, bc => 2, ik => 3, hi => 4, ui => 5, pq => 6, dc => 7}, |
|
3474 |
+ {ab => 1, bc => 2, ik => 3, hi => 4, ui => 5, pq => 6, dc => 8}, |
|
3475 |
+]; |
|
3476 |
+{ |
|
3477 |
+ my $query; |
|
3478 |
+ foreach my $row (@$rows) { |
|
3479 |
+ $query ||= $dbi->insert($row, table => 'table1', query => 1); |
|
3480 |
+ $dbi->execute($query, $row, filter => {ab => sub { $_[0] * 2 }}); |
|
3481 |
+ } |
|
3482 |
+ is_deeply($dbi->select(table => 'table1')->all, |
|
3483 |
+ [ |
|
3484 |
+ {ab => 2, bc => 2, ik => 3, hi => 4, ui => 5, pq => 6, dc => 7}, |
|
3485 |
+ {ab => 2, bc => 2, ik => 3, hi => 4, ui => 5, pq => 6, dc => 8}, |
|
3486 |
+ ] |
|
3487 |
+ ); |
|
3488 |
+} |
|
3489 |
+ |
|
3470 | 3490 |
$dbi->execute($DROP_TABLE->{0}); |
3471 | 3491 |
$dbi->execute("create table table1 (ab, bc, ik, hi, ui, pq, dc);"); |
3472 | 3492 |
$rows = [ |