Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3309390
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:38:06+00:00 2026-05-17T21:38:06+00:00

Im trying to make an operation of creating user network based on call detail

  • 0

Im trying to make an operation of creating user network based on call detail records in my CDR table.

To make things simple lets say Ive got CDR table :

CDRid
UserAId
UserBId

there is more than 100 mln records so table is quite big.

I reated user2user table:

UserAId
UserBId
NumberOfConnections

then using curos I iterate through each row in the table, then I make select statement:

if in user2user table there is record which has UserAId = UserAId from CDR record and UserBId = UserBId from CDR record then increase NumberOfConnections.

otherwise insert such a row which NumebrOfConnections = 1.

Quite simple task and it works as I said using cursor but it is very bad in performance (estimated time at my computer ~60 h).

I heard about Sql Server Integration Services that it has got better performance when we are talking about such big tables.

Problem is that I have no idea how to customize SSIS package for creating such task.

If anyone has got any idea how to help me, any good resources etc I would be really thankful.

Maybe there is any other good solution to make it work faster. I used indexes and variable tables and so on and performance is still pure.

thanks for help,

P.S.

This is script which I wrote and execution of this takes sth like 40 – 50 h.

DECLARE CDR_cursor CURSOR FOR 
SELECT CDRId, SubscriberAId, BNumber 
FROM dbo.CDR

OPEN CDR_cursor;

FETCH NEXT FROM CDR_cursor 
INTO @CdrId, @SubscriberAId, @BNumber;

WHILE @@FETCH_STATUS = 0

BEGIN

–here I check if there is a user with this number (Cause in CDR i only have SubscriberAId –and BNumber so that I need to check which one user is this (I only have users from
–network so that each time I cant find this user I add one which is outide network)

SELECT @UserBId = (Select UserID from dbo.Number where Number = @BNumber)
    IF (@UserBId is NULL)
    BEGIN
        INSERT INTO dbo.[User] (ID, Marked, InNetwork)
        VALUES (@OutUserId, 0, 0);

        INSERT into dbo.[Number](Number, UserId) values (@BNumber, @OutUserId);
        INSERT INTO dbo.User2User

        VALUES (@SubscriberAId, @OutUserId, 1)
        SET @OutUserId = @OutUserId - 1;
    END

    else

    BEGIN
        UPDATE dbo.User2User
        SET NumberOfConnections = NumberOfConnections + 1
        WHERE User1ID = @SubscriberAId AND User2ID = @UserBId
        -- Insert the row if the UPDATE statement failed.   
        if(@@ROWCOUNT = 0)
        BEGIN
            INSERT INTO dbo.User2User
            VALUES (@SubscriberAId, @UserBId, 1)
        END 
    END

    SET @Counter = @Counter + 1;

    if((@Counter % 100000) = 0)
    BEGIN
        PRINT Cast (@Counter as NVarchar(12));
    END
    FETCH NEXT FROM CDR_cursor 
    INTO @CdrId, @SubscriberAId, @BNumber;
END

CLOSE CDR_cursor;
DEALLOCATE CDR_cursor;
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T21:38:07+00:00Added an answer on May 17, 2026 at 9:38 pm

    The thing about SSIS is that it probably won’t be much faster than a cursor. It’s pretty much doing the same thing: reading the table record by record, processing the record and then moving to the next one. There are some advanced techniques in SSIS like sharding the data input that will help if you have heavy duty hardware, but without that it’s going to be pretty slow.

    A better solution would be to write an INSERT and an UPDATE statement that will give you what you want. With that you’ll be better able to take advantage of indices on the database. They would look something like:

    WITH SummaryCDR AS (UserAId, UserBId, Conns) AS
    (
    SELECT UserAId, UserBId, COUNT(1) FROM CDR
    GROUP BY UserAId, UserBId)    
    UPDATE user2user
    SET NumberOfConnections = NumberOfConnections + SummaryCDR.Conns
    FROM SummaryCDR
    WHERE SummaryCDR.UserAId = user2user.UserAId
    AND SummaryCDR.UserBId = user2user.UserBId
    
    INSERT INTO user2user (UserAId, UserBId, NumberOfConnections)
    SELECT CDR.UserAId, CDR.UserBId, Count(1)
    FROM CDR
    LEFT OUTER JOIN user2user
    ON user2user.UserAId = CDR.UserAId
    AND user2user.UserBId = CDR.UserBId
    WHERE user2user.UserAId IS NULL
    
    GROUP BY CDR.UserAId, CDR.UserBId
    

    (NB: I don’t have time to test this code, you’ll have to debug it yourself)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to make a simple calculator program where a user can opt
I'm trying make a login window where a user is prompted to enter their
I am fairly new to iOS development and trying make a simple app which
Trying to make a simple number clicker control for BlackBerry 6/7, like this: At
Trying to make an xna game, where the user needs to tap to stop
I trying to make a web service accessible to Matlab. I can call it
This is on .Net 4, full framework. I'm trying to make a simple winforms
I'm trying to make a function where I can give it an operation >
I'm trying to make a simple program to test the new .NET async functionality
I am a beginner to C#. I am trying to make a simple program

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.