|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-02-03 22:17 UTC] tony2001@php.net
[2006-02-03 22:38 UTC] support at kalador dot com
[2006-02-03 22:51 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 04:00:01 2025 UTC |
Description: ------------ I tried 3 ways to store big images (500K) in database and display in browser. lo works fast, as does using a "text" column and converting the image to base64 (and back for display). However, using bytea with escaping is very slow. Adding to the database is fine (it is fast), retrieving is the problem. Reproduce code: --------------- This code consumed my CPU and took 77 seconds to run for a 400K image: <?php // Connect to the database $dbconn = pg_connect('dbname=imagedb'); // Get the bytea data $res = pg_query("SELECT data FROM image WHERE name='big.gif'"); // Convert to binary and send to the browser header('Content-type: image/gif'); echo pg_unescape_bytea( pg_fetch_result($res,'data') ); ?> Expected result: ---------------- This should take less than 1 second. Using a text column and base64 escaping rather than a bytea column and pg_unescape_bytea takes less than 1 second on the same data. Actual result: -------------- Actually result - 77 seconds.