473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Column Sizes

Hi NG,

How do I find out the size of a column ?

I am retrieving large objects from the pg_largeobject table and creating a
files, I would like to know the length of the data column so that I can
implement buffering instead of writing hundreds of small chunks to disk.

Any help would be appreciated.

Thanks in advance,

Brett
Nov 12 '05 #1
6 4574
On Nov 12, 2003, at 11:04 AM, Brett Maton wrote:
Hi NG,

How do I find out the size of a column ?

I am retrieving large objects from the pg_largeobject table and
creating a
files, I would like to know the length of the data column so that I can
implement buffering instead of writing hundreds of small chunks to
disk.

Any help would be appreciated.

Thanks in advance,

Brett


I always check for the size this way:

select sum(length(data)) from pg_largeobject where loid = xxx;

Or if you want to know the size of an individual page:

select pageno, length(data) from pg_largeobject where loid = xxx order
by pageno;

Hope this help,

Adam Ruth
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #2
"Brett Maton" <br*********@itaccounting.co.uk> writes:
Hi NG,

How do I find out the size of a column ?

I am retrieving large objects from the pg_largeobject table and creating a
files, I would like to know the length of the data column so that I can
implement buffering instead of writing hundreds of small chunks to disk.


Funny, there doesn't seem to be an lo_size() function--I was sure
there was one. I'm not sure if there's a way to find out the size of
a large object without reading it all.

If you just do lo_read() in a loop with a reasonably large buffer it
should be fairly efficient.

-Doug

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #3
Thanks for the answers guys,

I ran a quick query lastnight select length(data) from pg_largeobject
where loid = xxxx which prompted my post.

The query returned 'n' rows of 2048 bytes and an incomplete "page" of say
236, as I wasn't really thinking about it that much I assumed for some
reason that the data column was limited to a maximum of 2048 bytes by the
database. I was hoping to select this value (2048) from a query
(like \d tablename describes the columns and sizes) to build a buffer
either a) large enough or b) sensibly proportioned.

Although my question may not be relevant to this particular issue there
are times that I would like to now the size of a particular column, and I
believe
that it's possible to get this value from the database using a query and
pg_catalog etc, just not sure how to achieve this.

Thanks again,

Brett
"Brett Maton" <br*********@itaccounting.co.uk> wrote in message
news:bo**********@news.hub.org...
Hi NG,

How do I find out the size of a column ?

I am retrieving large objects from the pg_largeobject table and creating a files, I would like to know the length of the data column so that I can
implement buffering instead of writing hundreds of small chunks to disk.

Any help would be appreciated.

Thanks in advance,

Brett

Nov 12 '05 #4
On Nov 13, 2003, at 2:47 AM, Brett Maton wrote:
Thanks for the answers guys,

I ran a quick query lastnight select length(data) from pg_largeobject
where loid = xxxx which prompted my post.

The query returned 'n' rows of 2048 bytes and an incomplete "page"
of say
236, as I wasn't really thinking about it that much I assumed for some
reason that the data column was limited to a maximum of 2048 bytes
by the
database. I was hoping to select this value (2048) from a query
(like \d tablename describes the columns and sizes) to build a buffer
either a) large enough or b) sensibly proportioned.

Although my question may not be relevant to this particular issue
there
are times that I would like to now the size of a particular column,
and I
believe
that it's possible to get this value from the database using a query
and
pg_catalog etc, just not sure how to achieve this.

Thanks again,

Brett
"Brett Maton" <br*********@itaccounting.co.uk> wrote in message
news:bo**********@news.hub.org...
Hi NG,

How do I find out the size of a column ?

I am retrieving large objects from the pg_largeobject table and
creating

a
files, I would like to know the length of the data column so that I
can
implement buffering instead of writing hundreds of small chunks to
disk.

Any help would be appreciated.

Thanks in advance,

Bret


The column type for pg_largeobject.data is bytea with no length
specified. That means, unfortunately, that there's no way to get the
size of the column from the catalog. It does seem that the large
object functions do split the data into 2k chunks, but it would
probably be a simple thing to check the source to determine if this is
always true. But it could always change in a future version.

Adam Ruth
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 12 '05 #5
Adam Ruth <ar***@intercation.com> writes:
... It does seem that the large
object functions do split the data into 2k chunks, but it would
probably be a simple thing to check the source to determine if this is
always true. But it could always change in a future version.


My recollection is that the large object chunk size is defined as BLCKSZ/4,
so you'd get 2K with the default 8K block size, but it could also be
4K or 8K with the other likely choices for block size.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 12 '05 #6
On Nov 12, 2003, at 11:04 AM, Brett Maton wrote:
Hi NG,

How do I find out the size of a column ?

I am retrieving large objects from the pg_largeobject table and
creating a
files, I would like to know the length of the data column so that I can
implement buffering instead of writing hundreds of small chunks to
disk.

Any help would be appreciated.

Thanks in advance,

Brett


I always check for the size this way:

select sum(length(data)) from pg_largeobject where loid = xxx;

Or if you want to know the size of an individual page:

select pageno, length(data) from pg_largeobject where loid = xxx order
by pageno;

Hope this help,

Adam Ruth
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: ScottyBaby | last post by:
Hi, I've run into a curious problem with MS SQL Server 8.0. Using sp_help and SQL Query Analyzer's object browser to view the columns returned by a view, I find that sp_help is reporting stale...
0
by: GroZZleR | last post by:
Hey all, How can you expand the column sizes to ALWAYS take up atleast 100% of the DataGrid / DataTable? Right now my columns look like this: http://www.grozzler.com/dump/dt_mine.png I...
5
by: Iams | last post by:
What do I have to do to get a column in a table to stay the same size no matter what is in the other tables? I've tried setting the width in px, in percentages, and nothing seems to work; for...
9
by: Kevin Westhead | last post by:
Can anyone confirm whether or not there are any limits imposed on the widths of autosized columns in a list-view. I've found that the autosizing appears to have an upper limit, i.e. it will not...
2
by: Starbuck | last post by:
Hi Is there anyway of capturing when the users adjusts the width of a datagrid column so the new column width can be stored. Thanks in advance
18
by: chimalus | last post by:
I am using a table with no column widths specified, letting the table layout manager do its thing for figuring out the column widths, and this works just fine. Now I want to make the table...
3
by: Oenone | last post by:
I have a project that creates a SqlDataAdapter and uses its Fill method to fill a DataTable with data from a user-provided query. From there I can obviously access details about the rows and...
1
by: tom taol | last post by:
Currently, there are 3 datasheets in a form. and, i changed column widths of each form(datasheet type) by the way, there is not keep the column width in ms access. for example, i close the form,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.