March 17, 2008 at 2:19 pm
This is an odd request, but...
If I want to track all information concerning a specific order in our database (the order_id is a primary key or foreign key found in most of our tables, so I want to run a select + join utilizing it), is there any way to estimate the size of the data?
A customer wants us to keep their order data available for longer than we typically keep it, so we estimate that we will be charging them more for this service, based on the increased data usage. Is there any way to track how much data/size is taken up by using select statement?
March 17, 2008 at 2:23 pm
You could use the information_schema.columns to get the size of the columns, sum it, and multiply it by the Count of the rows for that customer.
That should give you a start.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
March 17, 2008 at 3:01 pm
Like this:
Select SUM(
DATALENGTH(col1)
+ DATALENGTH(col2)
+ ...) As [TotalBytes]
From order
Where order_id = @customer_order_id
Repeat for all relevant tables and add them up.
[font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
Proactive Performance Solutions, Inc. [/font][font="Verdana"] "Performance is our middle name."[/font]
March 17, 2008 at 4:12 pm
Use the SELECT along with INTO to create a table. Use sp_SpaceUsed to see how big the table is.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply