Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / October 2006

Tip: Looking for answers? Try searching our database.

row-counts to BLOB size ratio

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pike - 27 Oct 2006 09:43 GMT
DB2 UDB v8.2 (FP11) on AIX 5.2.

I'm not an SQL guru, so please be gentle with me.

I have a table that contains a BLOB(312MB) column, and I'd like to
determine, in an efficient way, the row-counts to BLOB size ratio. The
output would be something like this:

BLOB Size (MB)    Rowcount
0-32                       2540
33-64                     5680
65-96                   56402
...
281-312                   560

Any assistance much appreciated.
Thank you.
Knut Stolze - 27 Oct 2006 10:23 GMT
> DB2 UDB v8.2 (FP11) on AIX 5.2.
>
[quoted text clipped - 10 lines]
> ...
> 281-312                   560

A simple grouping will do the trick:

SELECT ( LENGTH(blob_column) / 32 ) * 32 AS blob_size,
      COUNT(*) AS row_count
FROM   ...
GROUP BY ( LENGTH(blob_column) / 32 ) * 32
ORDER BY 1

If you want to have exactly your above formating, a little bit of polishing
is required:

SELECT RTRIM(CHAR(blob_size - 31)) || '-' || RTRIM(CHAR(blob_size)),
      row_count
FROM   ( SELECT ( LENGTH(blob_column) / 32 ) * 32 AS blob_size,
               COUNT(*) AS row_count
        FROM   ...
        GROUP BY ( LENGTH(blob_column) / 32 ) * 32 ) AS t
ORDER BY 1

Signature

Knut Stolze
DB2 Information Integration Development
IBM Germany

pike - 27 Oct 2006 13:13 GMT
Thank you very much Knut. Perfect.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.