dbTalk Databases Forums  

[BUGS] BUG #2236: extremely slow to get unescaped bytea data from db

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] BUG #2236: extremely slow to get unescaped bytea data from db in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kai Ronan
 
Posts: n/a

Default [BUGS] BUG #2236: extremely slow to get unescaped bytea data from db - 02-04-2006 , 02:46 PM







The following bug has been logged online:

Bug reference: 2236
Logged by: Kai Ronan
Email address: support (AT) kalador (DOT) com
PostgreSQL version: 8.0.1
Operating system: redhat linux
Description: extremely slow to get unescaped bytea data from db
Details:

Using php 5.1.2, trying to store images in database using bytea column and
pg_unescape_bytea() which is a PHP wrapper for PQunescapeBytea().

It took 77 seconds to extract a 400K gif image from the database. Using a
text column and base64 escaping, the same image took <1 to extract from the
database. lo functions also work fast. Loading images to the db is fast in
all cases.

Code snippet is:

<?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') );
?>

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Reply With Quote
  #2  
Old   
Alvaro Herrera
 
Posts: n/a

Default Re: [BUGS] BUG #2236: extremely slow to get unescaped bytea data from db - 02-04-2006 , 04:22 PM






Kai Ronan wrote:

Quote:
// Get the bytea data
$res = pg_query("SELECT data FROM image WHERE name='big.gif'");
Do you have an index in the image.name column? What does an

EXPLAIN ANALYZE SELECT data FROM image WHERE name='big.gif'

say?

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.