{"id":579,"date":"2026-09-15T19:43:09","date_gmt":"2026-09-15T11:43:09","guid":{"rendered":"https:\/\/dangnh.cf\/?p=579"},"modified":"2026-09-15T19:43:11","modified_gmt":"2026-09-15T11:43:11","slug":"eloquent-chunk-va-sai-lam-chet-choc","status":"publish","type":"post","link":"https:\/\/dangnh.cf\/vi\/2026\/09\/15\/eloquent-chunk-va-sai-lam-chet-choc\/","title":{"rendered":"Eloquent chunk() v\u00e0 sai l\u1ea7m &#8220;ch\u1ebft ch\u00f3c&#8221;"},"content":{"rendered":"<figure class=\"wp-block-image alignwide size-large\"><a href=\"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"540\" data-attachment-id=\"578\" data-permalink=\"https:\/\/dangnh.cf\/vi\/mot-nguoi-ang-cua-canh-tren-cay-cao\/\" data-orig-file=\"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg?fit=1600%2C900&amp;ssl=1\" data-orig-size=\"1600,900\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;,&quot;alt&quot;:&quot;&quot;}\" data-image-title=\"mot-nguoi-ang-cua-canh-tren-cay-cao\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Photo by &lt;a href=&quot;https:\/\/unsplash.com\/@d_glazun0v?utm_source=WP+Agent&amp;#038;utm_medium=referral&quot;&gt;Dmytro Glazunov&lt;\/a&gt; on &lt;a href=&quot;https:\/\/unsplash.com\/?utm_source=WP+Agent&amp;#038;utm_medium=referral&quot;&gt;Unsplash&lt;\/a&gt;&lt;\/p&gt;\" data-large-file=\"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg?fit=960%2C540&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg?resize=960%2C540&#038;ssl=1\" alt=\"M\u1ed9t ng\u01b0\u1eddi \u0111ang c\u01b0a c\u00e0nh tr\u00ean c\u00e2y cao\" class=\"wp-image-578\" srcset=\"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg?w=1600&amp;ssl=1 1600w, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg?resize=1024%2C576&amp;ssl=1 1024w, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg?resize=768%2C432&amp;ssl=1 768w, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg?resize=1536%2C864&amp;ssl=1 1536w, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg?resize=18%2C10&amp;ssl=1 18w, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg?resize=1140%2C641&amp;ssl=1 1140w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/a><figcaption class=\"wp-element-caption\">C\u01b0a c\u00e1i c\u00e0nh m\u00ecnh \u0111ang ng\u1ed3i. Photo by <a href=\"https:\/\/unsplash.com\/@d_glazun0v?utm_source=WP+Agent&amp;utm_medium=referral\">Dmytro Glazunov<\/a> on <a href=\"https:\/\/unsplash.com\/?utm_source=WP+Agent&amp;utm_medium=referral\">Unsplash<\/a><\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">M\u1ea5y n\u0103m tr\u01b0\u1edbc t\u00f4i c\u00f3 vi\u1ebft m\u1ed9t artisan command \u0111\u1ec3 \u0111\u00e1nh d\u1ea5u \u0111\u01a1n h\u00e0ng c\u0169 l\u00e0 &#8220;\u0111\u00e3 \u0111\u1ea9y sang ERP&#8221; <code>sent to ERP<\/code>. B\u1ea3ng <code>orders<\/code> l\u00fac \u0111\u00f3 t\u1ea7m 2m rows. T\u00f4i d\u00f9ng <code>chunk()<\/code> nh\u01b0 1 th\u00f3i quen, ch\u1ea1y qua \u0111\u00eam, s\u00e1ng d\u1eady log b\u00e1o x\u1eed l\u00fd \u0111\u01b0\u1ee3c\u2026 h\u01a1n 1 tri\u1ec7u. C\u00f2n g\u1ea7n 1m orders n\u1eefa kh\u00f4ng \u0111\u01b0\u1ee3c process, ch\u01b0a ai \u0111\u1ee5ng t\u1edbi.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Kh\u00f4ng exception. Kh\u00f4ng error log. Exit code 0.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u0110\u00e2y l\u00e0 ki\u1ec3u bug t\u00f4i gh\u00e9t nh\u1ea5t: n\u00f3 kh\u00f4ng ch\u1ebft, n\u00f3 ch\u1ec9 l\u00e0m sai m\u1ed9t n\u1eeda r\u1ed3i report l\u00e0 Done.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">chunk() th\u1eadt ra l\u00e0m g\u00ec behind the scene?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Code c\u1ee7a t\u00f4i h\u1ed3i \u0111\u00f3, r\u00fat g\u1ecdn l\u1ea1i:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Order::where('exported', false)\n    -&gt;chunk(500, function ($orders) {\n        foreach ($orders as $order) {\n            $this-&gt;erp-&gt;push($order);\n            $order-&gt;update(&#91;'exported' =&gt; true]);\n        }\n    });<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">M\u1edf source Laravel ra xem (trait <code>Illuminate\\Database\\Concerns\\BuildsQueries<\/code>, hi\u1ec7n t\u1ea1i l\u00e0 b\u1ea3n 13.x nh\u01b0ng logic n\u00e0y c\u0169 h\u01a1n nhi\u1ec1u), <code>chunk()<\/code> ch\u1ec9 l\u00e0 m\u1ed9t v\u00f2ng <code>do \u2026 while<\/code>. Page 1 ch\u1ea1y <code>OFFSET 0 LIMIT 500<\/code>, page 2 ch\u1ea1y <code>OFFSET 500 LIMIT 500<\/code>, c\u1ee9 th\u1ebf cho t\u1edbi khi m\u1ed9t page tr\u1ea3 v\u1ec1 \u00edt h\u01a1n 500 row. M\u1ed7i v\u00f2ng l\u00e0 m\u1ed9t query m\u1edbi, ch\u1ea1y l\u1ea1i nguy\u00ean c\u00e1i <code>where<\/code> c\u1ee7a b\u1ea1n.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">V\u00ed d\u1ee5: <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Page 1 l\u1ea5y 500 \u0111\u01a1n c\u00f3 <code>exported = false<\/code>, x\u1eed l\u00fd xong th\u00ec 500 \u0111\u01a1n \u0111\u00f3 th\u00e0nh <code>exported = true<\/code>. <\/li>\n\n\n\n<li>Page 2 ch\u1ea1y query v\u1edbi <code>OFFSET 500<\/code>\u2026 tr\u00ean m\u1ed9t t\u1eadp k\u1ebft qu\u1ea3 v\u1eeba ng\u00f3t \u0111i 500 row. Ngh\u0129a l\u00e0 n\u00f3 nh\u1ea3y qua 500 \u0111\u01a1n k\u1ebf ti\u1ebfp m\u00e0 ch\u01b0a h\u1ec1 \u0111\u1ee5ng t\u1edbi.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">M\u1ed7i chunk x\u1eed l\u00fd b\u1ecf s\u00f3t <strong>\u0111\u00fang m\u1ed9t chunk.<\/strong> L\u00e0m m\u1ed9t n\u1eeda, qu\u00ean m\u1ed9t n\u1eeda&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Docs Laravel c\u00f3 n\u00f3i v\u1ee5 n\u00e0y. M\u1ed9t \u0111o\u1ea1n warning ngay d\u01b0\u1edbi v\u00ed d\u1ee5 <code>chunk()<\/code>, b\u1ea3o n\u1ebfu b\u1ea1n filter theo column m\u00e0 b\u1ea1n s\u1ebd update trong l\u00fac l\u1eb7p th\u00ec d\u00f9ng <code>chunkById()<\/code>. \u0110\u1ea3m b\u1ea3o t\u00f4i \u0111\u00e3 \u0111\u1ecdc l\u01b0\u1edbt qua \u0111o\u1ea1n \u0111\u00f3 \u00edt nh\u1ea5t ba l\u1ea7n tr\u01b0\u1edbc khi b\u1ecb c\u1eafn \ud83d\ude42<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">chunkById() kh\u00e1c g\u00ec m\u00e0 s\u1eeda \u0111\u01b0\u1ee3c?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><code>chunkById()<\/code> kh\u00f4ng d\u00f9ng OFFSET. N\u00f3 nh\u1edb <code>id<\/code> cu\u1ed1i c\u00f9ng c\u1ee7a chunk tr\u01b0\u1edbc, r\u1ed3i query k\u1ebf ti\u1ebfp l\u00e0 <code>WHERE id &gt; :lastId ORDER BY id ASC LIMIT 500<\/code> (function <code>forPageAfterId()<\/code> trong query builder, n\u1ebfu b\u1ea1n mu\u1ed1n t\u1ef1 ki\u1ec3m tra). Row b\u1ecb update hay b\u1ecb xo\u00e1 kh\u00f4ng \u1ea3nh h\u01b0\u1edfng g\u00ec, v\u00ec \u0111i\u1ec3m neo l\u00e0 <strong>id<\/strong>, kh\u00f4ng d\u00ednh g\u00ec t\u1edbi v\u1ecb tr\u00ed trong t\u1eadp k\u1ebft qu\u1ea3.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Order::where('exported', false)\n    -&gt;chunkById(500, function ($orders) {\n        foreach ($orders as $order) {\n            $this-&gt;erp-&gt;push($order);\n            $order-&gt;update(&#91;'exported' =&gt; true]);\n        }\n    });<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u0110\u1ed5i \u0111\u00fang m\u1ed9t c\u00e1i t\u00ean function. Hai tri\u1ec7u \u0111\u01a1n ch\u1ea1y s\u1ea1ch.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">C\u00f3 \u0111i\u1ec1u <code>chunkById()<\/code> c\u0169ng c\u00f3 v\u00e0i ch\u1ed7 d\u1ec5 v\u1ea5p m\u00e0 official docs n\u00f3i h\u01a1i ng\u1eafn.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Th\u1ee9 nh\u1ea5t, <code>orWhere<\/code> ph\u1ea3i <strong>b\u1ecdc trong closure<\/strong>. V\u00ec <code>chunkById()<\/code> t\u1ef1 nh\u00e9t th\u00eam <code>where id > ?<\/code> v\u00e0o cu\u1ed1i query, n\u00ean vi\u1ebft <code>where(a)->orWhere(b)->chunkById()<\/code> th\u00ec SQL sinh ra l\u00e0 <code>a OR b AND id > ?<\/code>. M\u1ea5y row kh\u1edbp <code>a<\/code> s\u1ebd quay l\u1ea1i \u1edf m\u1ecdi chunk, t\u1ec7 nh\u1ea5t l\u00e0 infinity loop. B\u1ecdc <code>where(function ($q) { \u2026 })<\/code> l\u00e0 xong.<\/li>\n\n\n\n<li>Th\u1ee9 hai, c\u00f3 join th\u00ec ph\u1ea3i ch\u1ec9 r\u00f5 column v\u00e0 alias: <code>chunkById(500, $callback, column: 'orders.id', alias: 'id')<\/code>. Kh\u00f4ng th\u00ec h\u00ean xui: MySQL b\u00e1o ambiguous column, Laravel n\u00e9m <code>RuntimeException<\/code> b\u1ea3o column kh\u00f4ng c\u00f3 trong result, ho\u1eb7c t\u1ec7 nh\u1ea5t l\u00e0 ch\u1ea1y \u00eam ru nh\u01b0ng neo nh\u1ea7m <code>id<\/code> c\u1ee7a joined table(s).<\/li>\n\n\n\n<li>Th\u1ee9 ba, \u0111\u1eebng <code>orderBy<\/code> th\u1ee9 kh\u00e1c tr\u01b0\u1edbc khi <code>chunkById()<\/code>. N\u00f3 ch\u1ec9 g\u1ee1 order theo c\u1ed9t id c\u1ee7a b\u1ea1n r\u1ed3i th\u00eam <code>ORDER BY id ASC<\/code> v\u00e0o sau, n\u00ean <code>orderBy('created_at')->chunkById()<\/code> cho ra <code>ORDER BY created_at, id<\/code> k\u00e8m <code>WHERE id > ?<\/code>. Sort theo m\u1ed9t c\u1ed9t, neo theo c\u1ed9t kh\u00e1c\u2026 k\u1ebft qu\u1ea3 l\u00e0 b\u1ecf s\u00f3t row m\u00e0 ch\u1eb3ng ai b\u00e1o.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">V\u1eady cursor() th\u00ec sao? C\u00f3 c\u1ee9u \u0111\u01b0\u1ee3c RAM kh\u00f4ng?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Th\u1ea5y chunk phi\u1ec1n, nhi\u1ec1u b\u1ea1n nh\u1ea3y sang <code>cursor()<\/code>. Docs n\u00f3i cursor ch\u1ec9 gi\u1eef m\u1ed9t model trong RAM t\u1ea1i m\u1ed9t th\u1eddi \u0111i\u1ec3m. \u0110\u00fang. Nh\u01b0ng k\u00e9o xu\u1ed1ng th\u00eam v\u00e0i d\u00f2ng n\u1eefa c\u00f3 m\u1ed9t c\u00e1i note kh\u00e1c, v\u00e0 c\u00e1i n\u00e0y \u00edt ng\u01b0\u1eddi \u0111\u1ecdc t\u1edbi.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>cursor()<\/code> ch\u1ea1y \u0111\u00fang m\u1ed9t query, r\u1ed3i d\u00f9ng generator (<code>yield<\/code>) \u0111\u1ec3 hydrate t\u1eebng row th\u00e0nh model. Model th\u00ec \u0111\u00fang l\u00e0 ch\u1ec9 c\u00f3 m\u1ed9t. Nh\u01b0ng raw result set th\u00ec PDO \u0111\u00e3 k\u00e9o h\u1ebft v\u1ec1 PHP ngay l\u00fac execute, v\u00ec PDO MySQL m\u1eb7c \u0111\u1ecbnh ch\u1ea1y <strong>buffered query<\/strong>. Hai tri\u1ec7u row raw v\u1eabn n\u1eb1m trong RAM c\u1ee7a process, ch\u1ec9 l\u00e0 n\u1eb1m d\u01b0\u1edbi d\u1ea1ng array thay v\u00ec object Eloquent.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">N\u00ean <code>cursor()<\/code> ch\u1ebft ch\u1eadm h\u01a1n <code>get()<\/code>. Ch\u1eadm h\u01a1n th\u00f4i. V\u1eabn ch\u1ebft.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">C\u00f3 m\u1ed9t c\u00e1ch &#8220;hack&#8221; l\u00e0 t\u1eaft buffer \u0111i: th\u00eam <code>PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false<\/code> trong <code>config\/database.php<\/code>. L\u00fac \u0111\u00f3 cursor m\u1edbi th\u1eadt s\u1ef1 stream t\u1eebng row t\u1eeb MySQL. <strong>Nh\u01b0ng<\/strong>, b\u1ea1n tr\u1ea3 gi\u00e1 \u1edf ch\u1ed7: khi m\u1ed9t unbuffered query ch\u01b0a fetch h\u1ebft, connection \u0111\u00f3 kh\u00f4ng \u0111\u01b0\u1ee3c ch\u1ea1y b\u1ea5t k\u1ef3 query n\u00e0o kh\u00e1c -> locked. C\u00e1i <code>$order->update()<\/code> b\u00ean trong <code>foreach<\/code> s\u1ebd throw &#8220;Cannot execute queries while other unbuffered queries are active&#8221;. \u0110\u00fang c\u00e1i loop \u1edf tr\u00ean, ch\u1ebft ngay row \u0111\u1ea7u ti\u00ean.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">T\u00f4i t\u1eebng th\u1ea5y m\u1ed9t team set option n\u00e0y global cho c\u1ea3 app. C\u1ea3 tu\u1ea7n sau v\u1eabn c\u00f2n l\u01b0\u1ee3m bug \u1edf nh\u1eefng ch\u1ed7 ch\u1eb3ng li\u00ean quan g\u00ec t\u1edbi c\u00e1i command ban \u0111\u1ea7u. \u0110\u1eebng l\u00e0m v\u1eady.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Th\u00eam m\u1ed9t h\u1ea1n ch\u1ebf n\u1eefa: <code>cursor()<\/code> kh\u00f4ng eager load. <code>Order::with('items')-&gt;cursor()<\/code> th\u00ec c\u00e1i <code>with()<\/code> coi nh\u01b0 kh\u00f4ng c\u00f3 t\u00e1c d\u1ee5ng, v\u00e0 b\u1ea1n c\u00f3 N+1 ngay trong c\u00e1i loop m\u00ecnh t\u01b0\u1edfng l\u00e0 t\u1ed1i \u01b0u nh\u1ea5t project.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">V\u1eady cu\u1ed1i c\u00f9ng d\u00f9ng c\u00e1i g\u00ec?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">C\u00e2u tr\u1ea3 l\u1eddi: <code>lazyById()<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Order::where('exported', false)\n    -&gt;with('items')\n    -&gt;lazyById(500, column: 'id')\n    -&gt;each(function (Order $order) {\n        $this-&gt;erp-&gt;push($order);\n        $order-&gt;update(&#91;'exported' =&gt; true]);\n    });<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">B\u00ean trong n\u00f3 v\u1eabn l\u00e0 chunkById, t\u1ee9c l\u00e0 query theo id, update trong loop tho\u1ea3i m\u00e1i. Nh\u01b0ng b\u1ea1n nh\u1eadn v\u1ec1 m\u1ed9t <code>LazyCollection<\/code>, vi\u1ebft <code>foreach<\/code> hay chain <code>filter()<\/code>, <code>map()<\/code> nh\u01b0 collection b\u00ecnh th\u01b0\u1eddng thay v\u00ec nh\u00e9t h\u1ebft logic v\u00e0o callback. Eager load ch\u1ea1y \u0111\u01b0\u1ee3c v\u00ec m\u1ed7i chunk l\u00e0 m\u1ed9t Collection th\u1eadt. RAM t\u1ed1i \u0111a 500 model m\u1ed9t l\u00fac, v\u00e0 raw buffer c\u1ee7a PDO c\u0169ng ch\u1ec9 500 row, v\u00ec m\u1ed7i chunk l\u00e0 m\u1ed9t query ri\u00eang.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">C\u00e1ch t\u00f4i ch\u1ecdn b\u00e2y gi\u1edd, sau nhi\u1ec1u l\u1ea7n b\u1ecb th\u1ed1n:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>D\u01b0\u1edbi v\u00e0i ch\u1ee5c ngh\u00ecn row, \u0111\u1ecdc xong kh\u00f4ng update: <code>get()<\/code> cho l\u1eb9, \u0111\u1eebng l\u00e0m m\u00e0u.<\/li>\n\n\n\n<li>\u0110\u1ecdc nhi\u1ec1u, ch\u1ec9 \u0111\u1ecdc, c\u1ea7n nhanh v\u00e0 kh\u00f4ng c\u1ea7n relation: <code>cursor()<\/code>, ch\u1ea5p nh\u1eadn buffer.<\/li>\n\n\n\n<li>C\u00f3 update hay delete row trong loop: <code>chunkById()<\/code> ho\u1eb7c <code>lazyById()<\/code>. Kh\u00f4ng c\u00f3 l\u1ef1a ch\u1ecdn th\u1ee9 ba.<\/li>\n\n\n\n<li>C\u1ea7n eager load: <code>lazyById()<\/code>.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">C\u00f2n <code>chunk()<\/code> th\u01b0\u1eddng th\u00ec v\u1eabn \u1ed5n khi <code>where<\/code> kh\u00f4ng \u0111\u1ee5ng t\u1edbi column b\u1ea1n s\u1ebd update. V\u00ed d\u1ee5 filter theo <code>created_at<\/code> r\u1ed3i update <code>exported<\/code>, chunk ch\u1ea1y \u0111\u00fang. Nh\u01b0ng ai d\u00e1m ch\u1eafc s\u00e1u th\u00e1ng n\u1eefa kh\u00f4ng c\u00f3 \u00f4ng n\u00e0o th\u00eam <code>where('exported', false)<\/code> v\u00e0o cho &#8220;t\u1ed1i \u01b0u&#8221;?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">N\u1ebfu b\u1ea1n t\u1eebng b\u1ecb <code>chunk()<\/code> c\u1eafn theo ki\u1ec3u kh\u00e1c, k\u1ec3 t\u00f4i nghe d\u01b0\u1edbi comment. T\u00f4i nghi l\u00e0 c\u00f2n v\u00e0i bi\u1ebfn th\u1ec3 n\u1eefa m\u00e0 m\u00ecnh ch\u01b0a g\u1eb7p.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Peace!<\/p>\n\n\n\n<p class=\"has-small-font-size wp-block-paragraph\">\u1ea2nh: Dmytro Glazunov tr\u00ean Unsplash (Unsplash License) \u2014 <a href=\"https:\/\/unsplash.com\/photos\/person-pruning-branches-of-a-large-tree-KBiETehYWdU\">https:\/\/unsplash.com\/photos\/person-pruning-branches-of-a-large-tree-KBiETehYWdU<\/a><\/p>","protected":false},"excerpt":{"rendered":"<p>Eloquent chunk() b\u1ecf s\u00f3t m\u1ed9t n\u1eeda s\u1ed1 row khi b\u1ea1n update trong l\u00fac l\u1eb7p, c\u00f2n cursor() v\u1eabn tr\u00e0n RAM v\u00ec PDO buffer. V\u00ec sao, v\u00e0 khi n\u00e0o d\u00f9ng chunkById hay lazyById.<\/p>","protected":false},"author":1,"featured_media":578,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[5],"tags":[40,39,38,41,15],"class_list":["post-579","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-php","tag-database","tag-eloquent","tag-laravel","tag-performance","tag-php"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Eloquent chunk() v\u00e0 sai l\u1ea7m &quot;ch\u1ebft ch\u00f3c&quot; - Mark Nguyen<\/title>\n<meta name=\"description\" content=\"Eloquent chunk() b\u1ecf s\u00f3t m\u1ed9t n\u1eeda s\u1ed1 row khi b\u1ea1n update trong l\u00fac l\u1eb7p, c\u00f2n cursor() v\u1eabn tr\u00e0n RAM v\u00ec PDO buffer. V\u00ec sao, v\u00e0 khi n\u00e0o d\u00f9ng chunkById hay lazyById.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dangnh.cf\/vi\/2026\/09\/15\/eloquent-chunk-va-sai-lam-chet-choc\/\" \/>\n<meta property=\"og:locale\" content=\"vi_VN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Eloquent chunk() v\u00e0 sai l\u1ea7m &quot;ch\u1ebft ch\u00f3c&quot; - Mark Nguyen\" \/>\n<meta property=\"og:description\" content=\"Eloquent chunk() b\u1ecf s\u00f3t m\u1ed9t n\u1eeda s\u1ed1 row khi b\u1ea1n update trong l\u00fac l\u1eb7p, c\u00f2n cursor() v\u1eabn tr\u00e0n RAM v\u00ec PDO buffer. V\u00ec sao, v\u00e0 khi n\u00e0o d\u00f9ng chunkById hay lazyById.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dangnh.cf\/vi\/2026\/09\/15\/eloquent-chunk-va-sai-lam-chet-choc\/\" \/>\n<meta property=\"og:site_name\" content=\"Mark Nguyen\" \/>\n<meta property=\"article:published_time\" content=\"2026-09-15T11:43:09+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-09-15T11:43:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/dangnh.cf\/wp-content\/uploads\/2026\/09\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1600\" \/>\n\t<meta property=\"og:image:height\" content=\"900\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 ph\u00fat\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/dangnh.cf\\\/2026\\\/09\\\/15\\\/eloquent-chunk-va-sai-lam-chet-choc\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/dangnh.cf\\\/2026\\\/09\\\/15\\\/eloquent-chunk-va-sai-lam-chet-choc\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/dangnh.cf\\\/vi\\\/#\\\/schema\\\/person\\\/8f3b9db3b250186af217fbeec88eda9c\"},\"headline\":\"Eloquent chunk() v\u00e0 sai l\u1ea7m &#8220;ch\u1ebft ch\u00f3c&#8221;\",\"datePublished\":\"2026-09-15T11:43:09+00:00\",\"dateModified\":\"2026-09-15T11:43:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/dangnh.cf\\\/2026\\\/09\\\/15\\\/eloquent-chunk-va-sai-lam-chet-choc\\\/\"},\"wordCount\":1322,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/dangnh.cf\\\/vi\\\/#\\\/schema\\\/person\\\/8f3b9db3b250186af217fbeec88eda9c\"},\"image\":{\"@id\":\"https:\\\/\\\/dangnh.cf\\\/2026\\\/09\\\/15\\\/eloquent-chunk-va-sai-lam-chet-choc\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/dangnh.cf\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg?fit=1600%2C900&ssl=1\",\"keywords\":[\"Database\",\"Eloquent\",\"Laravel\",\"Performance\",\"php\"],\"articleSection\":[\"PHP\"],\"inLanguage\":\"vi\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/dangnh.cf\\\/2026\\\/09\\\/15\\\/eloquent-chunk-va-sai-lam-chet-choc\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/dangnh.cf\\\/2026\\\/09\\\/15\\\/eloquent-chunk-va-sai-lam-chet-choc\\\/\",\"url\":\"https:\\\/\\\/dangnh.cf\\\/2026\\\/09\\\/15\\\/eloquent-chunk-va-sai-lam-chet-choc\\\/\",\"name\":\"Eloquent chunk() v\u00e0 sai l\u1ea7m \\\"ch\u1ebft ch\u00f3c\\\" - Mark Nguyen\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/dangnh.cf\\\/vi\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/dangnh.cf\\\/2026\\\/09\\\/15\\\/eloquent-chunk-va-sai-lam-chet-choc\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/dangnh.cf\\\/2026\\\/09\\\/15\\\/eloquent-chunk-va-sai-lam-chet-choc\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/dangnh.cf\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg?fit=1600%2C900&ssl=1\",\"datePublished\":\"2026-09-15T11:43:09+00:00\",\"dateModified\":\"2026-09-15T11:43:11+00:00\",\"description\":\"Eloquent chunk() b\u1ecf s\u00f3t m\u1ed9t n\u1eeda s\u1ed1 row khi b\u1ea1n update trong l\u00fac l\u1eb7p, c\u00f2n cursor() v\u1eabn tr\u00e0n RAM v\u00ec PDO buffer. V\u00ec sao, v\u00e0 khi n\u00e0o d\u00f9ng chunkById hay lazyById.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/dangnh.cf\\\/2026\\\/09\\\/15\\\/eloquent-chunk-va-sai-lam-chet-choc\\\/#breadcrumb\"},\"inLanguage\":\"vi\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/dangnh.cf\\\/2026\\\/09\\\/15\\\/eloquent-chunk-va-sai-lam-chet-choc\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"vi\",\"@id\":\"https:\\\/\\\/dangnh.cf\\\/2026\\\/09\\\/15\\\/eloquent-chunk-va-sai-lam-chet-choc\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/dangnh.cf\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg?fit=1600%2C900&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/dangnh.cf\\\/wp-content\\\/uploads\\\/2026\\\/09\\\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg?fit=1600%2C900&ssl=1\",\"width\":1600,\"height\":900,\"caption\":\"Photo by Dmytro Glazunov on Unsplash\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/dangnh.cf\\\/2026\\\/09\\\/15\\\/eloquent-chunk-va-sai-lam-chet-choc\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/dangnh.cf\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Eloquent chunk() v\u00e0 sai l\u1ea7m &#8220;ch\u1ebft ch\u00f3c&#8221;\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/dangnh.cf\\\/vi\\\/#website\",\"url\":\"https:\\\/\\\/dangnh.cf\\\/vi\\\/\",\"name\":\"Mark Nguyen\",\"description\":\"I build the e-commerce backends customers never see \u2014 payments, integrations, and AI features that actually ship.\",\"publisher\":{\"@id\":\"https:\\\/\\\/dangnh.cf\\\/vi\\\/#\\\/schema\\\/person\\\/8f3b9db3b250186af217fbeec88eda9c\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/dangnh.cf\\\/vi\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"vi\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/dangnh.cf\\\/vi\\\/#\\\/schema\\\/person\\\/8f3b9db3b250186af217fbeec88eda9c\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"vi\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d838feab6bbd5e774c608b656a29ab0d54981b88fa4b563a83d7635108b6c76e?s=96&d=retro&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d838feab6bbd5e774c608b656a29ab0d54981b88fa4b563a83d7635108b6c76e?s=96&d=retro&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d838feab6bbd5e774c608b656a29ab0d54981b88fa4b563a83d7635108b6c76e?s=96&d=retro&r=g\",\"caption\":\"admin\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d838feab6bbd5e774c608b656a29ab0d54981b88fa4b563a83d7635108b6c76e?s=96&d=retro&r=g\"},\"description\":\"Dang Nguyen Hai (Mark) is a senior fullstack engineer in Ho Chi Minh City with 13+ years building e-commerce backends, payment systems and the AI features that sit on top of them. He works with Shopware and Laravel, and writes here about PHP internals, e-commerce architecture and getting AI features to behave in production.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/mark-nguyen-4027458b\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Eloquent chunk() v\u00e0 sai l\u1ea7m \"ch\u1ebft ch\u00f3c\" - Mark Nguyen","description":"Eloquent chunk() b\u1ecf s\u00f3t m\u1ed9t n\u1eeda s\u1ed1 row khi b\u1ea1n update trong l\u00fac l\u1eb7p, c\u00f2n cursor() v\u1eabn tr\u00e0n RAM v\u00ec PDO buffer. V\u00ec sao, v\u00e0 khi n\u00e0o d\u00f9ng chunkById hay lazyById.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/dangnh.cf\/vi\/2026\/09\/15\/eloquent-chunk-va-sai-lam-chet-choc\/","og_locale":"vi_VN","og_type":"article","og_title":"Eloquent chunk() v\u00e0 sai l\u1ea7m \"ch\u1ebft ch\u00f3c\" - Mark Nguyen","og_description":"Eloquent chunk() b\u1ecf s\u00f3t m\u1ed9t n\u1eeda s\u1ed1 row khi b\u1ea1n update trong l\u00fac l\u1eb7p, c\u00f2n cursor() v\u1eabn tr\u00e0n RAM v\u00ec PDO buffer. V\u00ec sao, v\u00e0 khi n\u00e0o d\u00f9ng chunkById hay lazyById.","og_url":"https:\/\/dangnh.cf\/vi\/2026\/09\/15\/eloquent-chunk-va-sai-lam-chet-choc\/","og_site_name":"Mark Nguyen","article_published_time":"2026-09-15T11:43:09+00:00","article_modified_time":"2026-09-15T11:43:11+00:00","og_image":[{"width":1600,"height":900,"url":"https:\/\/dangnh.cf\/wp-content\/uploads\/2026\/09\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi":"admin","\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc":"5 ph\u00fat"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/dangnh.cf\/2026\/09\/15\/eloquent-chunk-va-sai-lam-chet-choc\/#article","isPartOf":{"@id":"https:\/\/dangnh.cf\/2026\/09\/15\/eloquent-chunk-va-sai-lam-chet-choc\/"},"author":{"name":"admin","@id":"https:\/\/dangnh.cf\/vi\/#\/schema\/person\/8f3b9db3b250186af217fbeec88eda9c"},"headline":"Eloquent chunk() v\u00e0 sai l\u1ea7m &#8220;ch\u1ebft ch\u00f3c&#8221;","datePublished":"2026-09-15T11:43:09+00:00","dateModified":"2026-09-15T11:43:11+00:00","mainEntityOfPage":{"@id":"https:\/\/dangnh.cf\/2026\/09\/15\/eloquent-chunk-va-sai-lam-chet-choc\/"},"wordCount":1322,"commentCount":0,"publisher":{"@id":"https:\/\/dangnh.cf\/vi\/#\/schema\/person\/8f3b9db3b250186af217fbeec88eda9c"},"image":{"@id":"https:\/\/dangnh.cf\/2026\/09\/15\/eloquent-chunk-va-sai-lam-chet-choc\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg?fit=1600%2C900&ssl=1","keywords":["Database","Eloquent","Laravel","Performance","php"],"articleSection":["PHP"],"inLanguage":"vi","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/dangnh.cf\/2026\/09\/15\/eloquent-chunk-va-sai-lam-chet-choc\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/dangnh.cf\/2026\/09\/15\/eloquent-chunk-va-sai-lam-chet-choc\/","url":"https:\/\/dangnh.cf\/2026\/09\/15\/eloquent-chunk-va-sai-lam-chet-choc\/","name":"Eloquent chunk() v\u00e0 sai l\u1ea7m \"ch\u1ebft ch\u00f3c\" - Mark Nguyen","isPartOf":{"@id":"https:\/\/dangnh.cf\/vi\/#website"},"primaryImageOfPage":{"@id":"https:\/\/dangnh.cf\/2026\/09\/15\/eloquent-chunk-va-sai-lam-chet-choc\/#primaryimage"},"image":{"@id":"https:\/\/dangnh.cf\/2026\/09\/15\/eloquent-chunk-va-sai-lam-chet-choc\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg?fit=1600%2C900&ssl=1","datePublished":"2026-09-15T11:43:09+00:00","dateModified":"2026-09-15T11:43:11+00:00","description":"Eloquent chunk() b\u1ecf s\u00f3t m\u1ed9t n\u1eeda s\u1ed1 row khi b\u1ea1n update trong l\u00fac l\u1eb7p, c\u00f2n cursor() v\u1eabn tr\u00e0n RAM v\u00ec PDO buffer. V\u00ec sao, v\u00e0 khi n\u00e0o d\u00f9ng chunkById hay lazyById.","breadcrumb":{"@id":"https:\/\/dangnh.cf\/2026\/09\/15\/eloquent-chunk-va-sai-lam-chet-choc\/#breadcrumb"},"inLanguage":"vi","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dangnh.cf\/2026\/09\/15\/eloquent-chunk-va-sai-lam-chet-choc\/"]}]},{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/dangnh.cf\/2026\/09\/15\/eloquent-chunk-va-sai-lam-chet-choc\/#primaryimage","url":"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg?fit=1600%2C900&ssl=1","contentUrl":"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg?fit=1600%2C900&ssl=1","width":1600,"height":900,"caption":"Photo by Dmytro Glazunov on Unsplash"},{"@type":"BreadcrumbList","@id":"https:\/\/dangnh.cf\/2026\/09\/15\/eloquent-chunk-va-sai-lam-chet-choc\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dangnh.cf\/"},{"@type":"ListItem","position":2,"name":"Eloquent chunk() v\u00e0 sai l\u1ea7m &#8220;ch\u1ebft ch\u00f3c&#8221;"}]},{"@type":"WebSite","@id":"https:\/\/dangnh.cf\/vi\/#website","url":"https:\/\/dangnh.cf\/vi\/","name":"Mark Nguyen","description":"I build the e-commerce backends customers never see \u2014 payments, integrations, and AI features that actually ship.","publisher":{"@id":"https:\/\/dangnh.cf\/vi\/#\/schema\/person\/8f3b9db3b250186af217fbeec88eda9c"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dangnh.cf\/vi\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"vi"},{"@type":["Person","Organization"],"@id":"https:\/\/dangnh.cf\/vi\/#\/schema\/person\/8f3b9db3b250186af217fbeec88eda9c","name":"admin","image":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/secure.gravatar.com\/avatar\/d838feab6bbd5e774c608b656a29ab0d54981b88fa4b563a83d7635108b6c76e?s=96&d=retro&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d838feab6bbd5e774c608b656a29ab0d54981b88fa4b563a83d7635108b6c76e?s=96&d=retro&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d838feab6bbd5e774c608b656a29ab0d54981b88fa4b563a83d7635108b6c76e?s=96&d=retro&r=g","caption":"admin"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/d838feab6bbd5e774c608b656a29ab0d54981b88fa4b563a83d7635108b6c76e?s=96&d=retro&r=g"},"description":"Dang Nguyen Hai (Mark) is a senior fullstack engineer in Ho Chi Minh City with 13+ years building e-commerce backends, payment systems and the AI features that sit on top of them. He works with Shopware and Laravel, and writes here about PHP internals, e-commerce architecture and getting AI features to behave in production.","sameAs":["https:\/\/www.linkedin.com\/in\/mark-nguyen-4027458b"]}]}},"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9w3NP-9l","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":473,"url":"https:\/\/dangnh.cf\/vi\/2025\/11\/05\/ban-dung-cho-developer\/","url_meta":{"origin":579,"position":0},"title":"Standing desk &#8211; V\u1eadt trang tr\u00ed \u0111\u1eaft ti\u1ec1n hay m\u1eb9o hack productivity?","author":"admin","date":"Th\u00e1ng 11 5, 2025","format":false,"excerpt":"Mua b\u00e0n \u0111\u1ee9ng, t\u00f4i t\u01b0\u1edfng m\u00ecnh s\u1ebd th\u00e0nh si\u00eau nh\u00e2n n\u0103ng su\u1ea5t. Th\u1ef1c t\u1ebf th\u00ec n\u00f3 th\u00e0nh c\u00e1i c\u1edb ho\u00e0n h\u1ea3o \u0111\u1ec3\u2026 kh\u00f4ng ng\u1ed3i y\u00ean. V\u00e0i ghi ch\u00e9p th\u1eadt l\u00f2ng c\u1ee7a m\u1ed9t th\u1eb1ng dev.","rel":"","context":"Trong \"productivity hack\"","block_context":{"text":"productivity hack","link":"https:\/\/dangnh.cf\/vi\/tag\/productivity-hack\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2025\/11\/image-1.png?fit=800%2C1200&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2025\/11\/image-1.png?fit=800%2C1200&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2025\/11\/image-1.png?fit=800%2C1200&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2025\/11\/image-1.png?fit=800%2C1200&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":584,"url":"https:\/\/dangnh.cf\/vi\/2026\/09\/16\/lam-cho-client-duc-tu-sai-gon-lech-5-tieng-la-suong-hay-kho\/","url_meta":{"origin":579,"position":1},"title":"L\u00e0m cho client \u0110\u1ee9c t\u1eeb S\u00e0i G\u00f2n: l\u1ec7ch 5 ti\u1ebfng l\u00e0 s\u01b0\u1edbng hay kh\u1ed5?","author":"admin","date":"Th\u00e1ng 9 16, 2026","format":false,"excerpt":"L\u00e0m forward-deployed cho kh\u00e1ch \u0110\u1ee9c t\u1eeb S\u00e0i G\u00f2n: l\u1ec7ch 5 ti\u1ebfng, quy tr\u00ecnh Freigabe, GDPR v\u00e0 chuy\u1ec7n paste order v\u00e0o ChatGPT. H\u1ecdc ph\u00ed m\u1ed9t dev 13 n\u0103m \u0111\u00e3 tr\u1ea3.","rel":"","context":"Trong \"dev life\"","block_context":{"text":"dev life","link":"https:\/\/dangnh.cf\/vi\/tag\/dev-life\/"},"img":{"alt_text":"Ba chi\u1ebfc \u0111\u1ed3ng h\u1ed3 treo t\u01b0\u1eddng ch\u1ec9 ba m\u00fai gi\u1edd kh\u00e1c nhau","src":"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/ba-chiec-ong-ho-treo-tuong-chi-ba-mui-gio-khac-nhau.jpg?fit=1200%2C900&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/ba-chiec-ong-ho-treo-tuong-chi-ba-mui-gio-khac-nhau.jpg?fit=1200%2C900&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/ba-chiec-ong-ho-treo-tuong-chi-ba-mui-gio-khac-nhau.jpg?fit=1200%2C900&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/ba-chiec-ong-ho-treo-tuong-chi-ba-mui-gio-khac-nhau.jpg?fit=1200%2C900&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/ba-chiec-ong-ho-treo-tuong-chi-ba-mui-gio-khac-nhau.jpg?fit=1200%2C900&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":367,"url":"https:\/\/dangnh.cf\/vi\/2020\/01\/20\/service-container-di-sanh-dieu-voi-laravel\/","url_meta":{"origin":579,"position":2},"title":"Service Container &#038; DI &#8220;s\u00e0nh \u0111i\u1ec7u&#8221; v\u1edbi Laravel","author":"admin","date":"Th\u00e1ng 1 20, 2020","format":false,"excerpt":"Service Container l\u00e0 tr\u00e1i tim trong ki\u1ebfn tr\u00fac Laravel. Khi b\u00e0i to\u00e1n l\u1edbn d\u1ea7n v\u00e0 b\u1ea1n ph\u1ea3i qu\u1ea3n l\u00fd nhi\u1ec1u service c\u00f9ng dependency, \u0111\u00e2y l\u00e0 th\u1ee9 b\u1eaft bu\u1ed9c ph\u1ea3i hi\u1ec3u.","rel":"","context":"Trong &quot;PHP&quot;","block_context":{"text":"PHP","link":"https:\/\/dangnh.cf\/vi\/category\/web-development\/php\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2020\/01\/1_SstfI6yiEWj1mrnFrLTUdA-e1579505803935.jpeg?fit=900%2C600&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2020\/01\/1_SstfI6yiEWj1mrnFrLTUdA-e1579505803935.jpeg?fit=900%2C600&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2020\/01\/1_SstfI6yiEWj1mrnFrLTUdA-e1579505803935.jpeg?fit=900%2C600&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2020\/01\/1_SstfI6yiEWj1mrnFrLTUdA-e1579505803935.jpeg?fit=900%2C600&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":555,"url":"https:\/\/dangnh.cf\/vi\/2026\/09\/09\/migrate-payment-handler-len-shopware-6-7-mat-bao-lau-docs-noi-20-dong-thuc-te-thi\/","url_meta":{"origin":579,"position":3},"title":"Migrate payment handler l\u00ean Shopware 6.7 m\u1ea5t bao l\u00e2u? Docs n\u00f3i 20 d\u00f2ng, th\u1ef1c t\u1ebf th\u00ec\u2026","author":"admin","date":"Th\u00e1ng 9 9, 2026","format":false,"excerpt":"Migrate payment handler l\u00ean Shopware 6.7: AbstractPaymentHandler, order bi\u1ebfn m\u1ea5t kh\u1ecfi transaction struct, v\u00e0 race gi\u1eefa webhook v\u1edbi finalize l\u00e0m h\u1ecfng checkout.","rel":"","context":"Trong &quot;PHP&quot;","block_context":{"text":"PHP","link":"https:\/\/dangnh.cf\/vi\/category\/web-development\/php\/"},"img":{"alt_text":"M\u00e1y POS \u0111en v\u1edbi ho\u00e1 \u0111\u01a1n gi\u1ea5y d\u00e0i tr\u00ean n\u1ec1n cam \u2014 minh ho\u1ea1 payment flow trong Shopware 6.7","src":"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/may-pos-en-voi-hoa-on-giay-dai-tren-nen-cam-minh-hoa-payment.jpg?fit=1200%2C801&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/may-pos-en-voi-hoa-on-giay-dai-tren-nen-cam-minh-hoa-payment.jpg?fit=1200%2C801&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/may-pos-en-voi-hoa-on-giay-dai-tren-nen-cam-minh-hoa-payment.jpg?fit=1200%2C801&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/may-pos-en-voi-hoa-on-giay-dai-tren-nen-cam-minh-hoa-payment.jpg?fit=1200%2C801&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/may-pos-en-voi-hoa-on-giay-dai-tren-nen-cam-minh-hoa-payment.jpg?fit=1200%2C801&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":558,"url":"https:\/\/dangnh.cf\/vi\/2026\/09\/10\/ai-agent-tu-y-hoan-tien-nham-2-lan-va-idempotency-cuu-toi-the-nao\/","url_meta":{"origin":579,"position":4},"title":"AI agent t\u1ef1 \u00fd ho\u00e0n ti\u1ec1n NH\u1ea6M 2 l\u1ea7n, v\u00e0 idempotency c\u1ee9u t\u00f4i th\u1ebf n\u00e0o","author":"admin","date":"Th\u00e1ng 9 10, 2026","format":false,"excerpt":"AI agent g\u1ecdi tool refund trong production t\u01b0\u1edfng v\u00f4 h\u1ea1i, \u0111\u1ebfn khi n\u00f3 ho\u00e0n ti\u1ec1n m\u1ed9t \u0111\u01a1n h\u00e0ng 2 l\u1ea7n v\u00ec retry sau timeout. Idempotency key, structured error, saga pattern v\u00e0 b\u00e0i h\u1ecdc th\u1ef1c t\u1ebf khi cho AI quy\u1ec1n ghi v\u00e0o h\u1ec7 th\u1ed1ng thanh to\u00e1n.","rel":"","context":"Trong &quot;AI&quot;","block_context":{"text":"AI","link":"https:\/\/dangnh.cf\/vi\/category\/ai\/"},"img":{"alt_text":"Ch\u00eca kh\u00f3a v\u1eadt l\u00fd \u0111\u1eb7t tr\u00ean b\u00e0n ph\u00edm laptop, minh h\u1ecda cho kh\u00e1i ni\u1ec7m idempotency key","src":"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/chia-khoa-vat-ly-at-tren-ban-phim-laptop-minh-hoa-cho-khai-n.jpg?fit=1080%2C720&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/chia-khoa-vat-ly-at-tren-ban-phim-laptop-minh-hoa-cho-khai-n.jpg?fit=1080%2C720&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/chia-khoa-vat-ly-at-tren-ban-phim-laptop-minh-hoa-cho-khai-n.jpg?fit=1080%2C720&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/chia-khoa-vat-ly-at-tren-ban-phim-laptop-minh-hoa-cho-khai-n.jpg?fit=1080%2C720&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/chia-khoa-vat-ly-at-tren-ban-phim-laptop-minh-hoa-cho-khai-n.jpg?fit=1080%2C720&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":441,"url":"https:\/\/dangnh.cf\/vi\/2025\/06\/06\/rag-la-gi-va-tai-sao-may-ong-ai-cu-nhac-hoai\/","url_meta":{"origin":579,"position":5},"title":"RAG l\u00e0 g\u00ec? V\u00e0 t\u1ea1i sao m\u1ea5y \u00f4ng AI c\u1ee9 nh\u1eafc ho\u00e0i?","author":"admin","date":"Th\u00e1ng 6 6, 2025","format":false,"excerpt":"RAG (Retrieval-Augmented Generation) l\u00e0 c\u00e1ch gi\u00fap AI b\u1edbt \"n\u00f3i x\u1ea1o\" b\u1eb1ng vi\u1ec7c tra t\u00e0i li\u1ec7u tr\u01b0\u1edbc khi tr\u1ea3 l\u1eddi. Gi\u1ea3i th\u00edch d\u1ec5 hi\u1ec3u, k\u00e8m v\u00ed d\u1ee5 th\u1ef1c t\u1ebf v\u00e0 c\u00e1c b\u01b0\u1edbc tri\u1ec3n khai.","rel":"","context":"Trong &quot;AI&quot;","block_context":{"text":"AI","link":"https:\/\/dangnh.cf\/vi\/category\/ai\/"},"img":{"alt_text":"RAG trong AI","src":"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2025\/06\/ai-rag.png?fit=1200%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2025\/06\/ai-rag.png?fit=1200%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2025\/06\/ai-rag.png?fit=1200%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2025\/06\/ai-rag.png?fit=1200%2C800&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2025\/06\/ai-rag.png?fit=1200%2C800&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/dangnh.cf\/wp-content\/uploads\/2026\/09\/mot-nguoi-ang-cua-canh-tren-cay-cao.jpg?fit=1600%2C900&ssl=1","_links":{"self":[{"href":"https:\/\/dangnh.cf\/vi\/wp-json\/wp\/v2\/posts\/579","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dangnh.cf\/vi\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dangnh.cf\/vi\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dangnh.cf\/vi\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dangnh.cf\/vi\/wp-json\/wp\/v2\/comments?post=579"}],"version-history":[{"count":1,"href":"https:\/\/dangnh.cf\/vi\/wp-json\/wp\/v2\/posts\/579\/revisions"}],"predecessor-version":[{"id":582,"href":"https:\/\/dangnh.cf\/vi\/wp-json\/wp\/v2\/posts\/579\/revisions\/582"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dangnh.cf\/vi\/wp-json\/wp\/v2\/media\/578"}],"wp:attachment":[{"href":"https:\/\/dangnh.cf\/vi\/wp-json\/wp\/v2\/media?parent=579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dangnh.cf\/vi\/wp-json\/wp\/v2\/categories?post=579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dangnh.cf\/vi\/wp-json\/wp\/v2\/tags?post=579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}