views:

80

answers:

1

Is there a way to determine the size of the records returned by the database server?

+2  A: 

You can approximate the record size(s):

  • in the client application by altering the code to sum up and print the sizes of the fields you retrieved (you need to specify whether you can alter the client code), or
  • at the OS level, by using strace or truss to trace the byte amounts reported by read on the file handle associated to the database connection (using lsof to get the mapping between file handle and TCP/IP connection), provided that the OS is a flavour of Unix (you need to specify the operating system that either your client or database are running on), or
  • at the network level by using a tool such as wireshark or tcpdump, provided that the client connects to the server through a physical network interface (not through the loopback -- you need to specify how your client application is connecting to the database), or
  • at the database level by enabling appropriate logging or by looking at the database statistics (e.g. SHOW TABLE STATUS LIKE "my_table" on MySQL, SELECT SUM(avg_width) FROM pg_stats WHERE table_name LIKE 'my_table' for Postgres, etc.) for the average row size of the tables of interest, provided that the database supports it (you need to specify the database you are using) Otherwise you can compute your own statistics from a database dump.

V.

vladr