SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Copy Between 2 and 3 billion rows from a heap table with no key to a new partioned table.


Copy Between 2 and 3 billion rows from a heap table with no key to a new partioned table.

Author
Message
mishka-723908
mishka-723908
SSC-Enthusiastic
SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)SSC-Enthusiastic (157 reputation)

Group: General Forum Members
Points: 157 Visits: 245
Hello,

I need to copy Between 2 and 3 billion rows from a heap table with no identity to a new partioned table. The primary key is made up of a smallint value that represents a Month and BIGINT a loan_number.

--The partion key is a small int value.
--I have tried the approach of selecting by the partition key, but as you can imagine because of the amount of data each select can take quite some time.
--I also tried using an import\export task it started moving some data, but it is also extremly slow.
--The new table has 24 partitions. each partition represents 24 values of the partition key from 0 - 552

Here is the definition of the partitioned table. The heap table is the same except it does not have the identity column created_by\date attributes.

--Partitioned table
CREATE TABLE dbo.qc_partition
(
qc_partition_id BIGINT IDENTITY(1,1)
, pool_id CHAR(3) NOT NULL
, deal_no CHAR(5) NOT NULL
, group_no CHAR(3) NOT NULL
, servicer VARCHAR(4) NULL
, internal_loan_id CHAR(6) NOT NULL
, external_loan_id VARCHAR(18) NOT NULL
, last_int_p SMALLDATETIME NULL
, balance MONEY NULL
, int_rate NUMERIC(6, 3) NULL
, total_payment_due MONEY NULL
, sched_principal MONEY NULL
, sched_mnth_p MONEY NULL
, mba_stat VARCHAR(1) NULL
, ots_stat VARCHAR(1) NULL
, payment_hist VARCHAR(12) NULL
, exception VARCHAR(1) NULL
, start_date SMALLDATETIME NULL
, end_date SMALLDATETIME NULL
, fc_end_typ VARCHAR(1) NULL
, payoff_d SMALLDATETIME NULL
, payoff_r VARCHAR(1) NULL
, sell_date SMALLDATETIME NULL
, inv_bal MONEY NULL
, next_percent NUMERIC(6, 3) NULL
, loss_val MONEY NULL
, net_rate NUMERIC(7, 4) NULL
, period SMALLINT NOT NULL
, file_name CHAR(8) NOT NULL
, created_by VARCHAR(70) NOT NULL DEFAULT CURRENT_USER
, created_date DATETIME NOT NULL DEFAULT (GETDATE())
) ON partition_scheme_qc (period)


One more question about the indexing. I created the following index, but was wondering if anyone had better idea on that. Also, What would be the best way to create a clustered-index\primary key here.

CREATE NONCLUSTERED INDEX IX_period_external_loan_id
ON qc_partition (period, external_loan_id)
ON partition_scheme_qc (period)
GO


Does anyone have any ideas?

Thank you for your help
Orlando Colamatteo
Orlando Colamatteo
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14861 Visits: 14396
Related post. Direct replies here:

http://www.sqlservercentral.com/Forums/Topic1405106-146-1.aspx

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)SSC Guru (85K reputation)

Group: General Forum Members
Points: 85186 Visits: 41077
This is a duplicate post. Posting the same question over and over isn't the thing to do here. All it does is split resources and tick people off.

Please don't post any answers on this thread... instead, post them where this seems to have started....
http://www.sqlservercentral.com/Forums/Topic1405106-146-1.aspx

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search