Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The utilisation of parameters writes in the standard output so the performances are considerably descreased [DNET577] #546

Closed
firebird-automations opened this issue Nov 24, 2014 · 2 comments

Comments

@firebird-automations
Copy link

Submitted by: Pascal (webpac)

To insert datas in a Firebird database, I use a FbCommand with parameters and transactions to be as quick as possible.
But the FbCommand writes in the standard ouput all values of all parameters. So when with anoter database the job lasts one hour, with Firebird it lasts ten hours.

It's very important for me to get a fix and I can't go to production with this low performances.

The code is made to work with SQL Server, Oracle, MySQL, PostgreSQL and Firebird.

This is an example of code to reproduce:

   public void InsererEnregistrement\(string nomTable\)
    \{
        const IsolationLevel isolationLevel = IsolationLevel\.ReadUncommitted;
        const int nbreLigneTotal = 1000;

        var parametres = new List<string\>\(\);

        for \(int i = 1; i <= 50; i\+\+\)
            parametres\.Add\("@p" \+ i\);

        var commande = String\.Format\("INSERT INTO \{0\} VALUES \(" \+ parametres\.Aggregate\(\(a, b\) =\> a \+ ", " \+ b\) \+ "\)", nomTable\);

        using \(var connexion = new FbConnection\(\)\)
        \{
            connexion\.ConnectionString = ConnectionStringBuilder\.ConnectionString;

            connexion\.Open\(\);

            using \(var command = new FbCommand\(\)\)
            \{                  
                command\.Connection = connexion;
                command\.CommandText = commande;

                DbTransaction transaction = connexion\.BeginTransaction\(isolationLevel\);

                command\.Transaction = transaction;

                for \(int i = 1; i <= 25; i\+\+\)
                \{
                    var parametre = new FbParameter\(\);
                    parametre\.ParameterName = "@p" \+ i;
                    parametre\.DbType = DbType\.Int32;
                    command\.Parameters\.Add\(parametre\);
                \}

                for \(int i = 26; i <= 50; i\+\+\)
                \{
                    var parametre = new FbParameter\(\);
                    parametre\.ParameterName = "@p" \+ i;
                    parametre\.DbType = DbType\.String;
                    command\.Parameters\.Add\(parametre\);
                \}

                command\.Prepare\(\);

                for \(int i = 0; i <= nbreLigneTotal; i\+\+\)
                \{
                    command\.Parameters\[0\]\.Value = \(i \+ 1\) \* 100000;
                    command\.Parameters\[1\]\.Value = i;
                    command\.Parameters\[2\]\.Value = 0;

                    for \(int j = 4; j <= 25; j\+\+\)
                        command\.Parameters\[j \- 1\]\.Value = 1234567890;

                    for \(int j = 26; j <= 50; j\+\+\)
                        command\.Parameters\[j \- 1\]\.Value = "01234657890123456789012345678901234567890123456789";

                    command\.ExecuteNonQuery\(\);

                    if \(\(i \!= 0\) && \(\(i % 1000\) == 0\)\)
                    \{
                        transaction\.Commit\(\);
                        if \(i \!= nbreLigneTotal\)
                        \{
                            transaction = connexion\.BeginTransaction\(isolationLevel\);
                            command\.Transaction = transaction;
                        \}
                    \}
                \}
            \}
        \}
    \}

And for each row inserted, I got this in the standard output :
FirebirdSql.Data.FirebirdClient Information: 0 : Command:
INSERT INTO SMR8_MODIF_C50T50L0100000 VALUES (@p1, @p2, @p3, @P4, @p5, @p6, @P7, @p8, @p9, @p10, @p11, @p12, @P13, @p14, @P15, @p16, @p17, @p18, @p19, @p20, @p21, @p22, @p23, @p24, @p25, @P26, @p27, @p28, @p29, @p30, @p31, @P32, @p33, @p34, @p35, @p36, @P37, @p38, @p39, @p40, @p41, @p42, @P43, @p44, @p45, @p46, @P47, @p48, @p49, @p50)
Parameters:
Name:@p1 Type:Integer Used Value:100000
Name:@p2 Type:Integer Used Value:0
Name:@p3 Type:Integer Used Value:0
Name:@P4 Type:Integer Used Value:1234567890
Name:@p5 Type:Integer Used Value:1234567890
Name:@p6 Type:Integer Used Value:1234567890
Name:@P7 Type:Integer Used Value:1234567890
Name:@p8 Type:Integer Used Value:1234567890
Name:@p9 Type:Integer Used Value:1234567890
Name:@p10 Type:Integer Used Value:1234567890
Name:@p11 Type:Integer Used Value:1234567890
Name:@p12 Type:Integer Used Value:1234567890
Name:@P13 Type:Integer Used Value:1234567890
Name:@p14 Type:Integer Used Value:1234567890
Name:@P15 Type:Integer Used Value:1234567890
Name:@p16 Type:Integer Used Value:1234567890
Name:@p17 Type:Integer Used Value:1234567890
Name:@p18 Type:Integer Used Value:1234567890
Name:@p19 Type:Integer Used Value:1234567890
Name:@p20 Type:Integer Used Value:1234567890
Name:@p21 Type:Integer Used Value:1234567890
Name:@p22 Type:Integer Used Value:1234567890
Name:@p23 Type:Integer Used Value:1234567890
Name:@p24 Type:Integer Used Value:1234567890
Name:@p25 Type:Integer Used Value:1234567890
Name:@P26 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@p27 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@p28 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@p29 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@p30 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@p31 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@P32 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@p33 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@p34 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@p35 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@p36 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@P37 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@p38 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@p39 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@p40 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@p41 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@p42 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@P43 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@p44 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@p45 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@p46 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@P47 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@p48 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@p49 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789
Name:@p50 Type:VarChar Used Value:01234657890123456789012345678901234567890123456789

If you think, it's important to continue to write parameters in the standard output, you can put in the setup the bin/release dll without writing and the bin/debug dll with writing.
So the developpers can use the release or the debug version depending of their needs.

Regards,

@firebird-automations
Copy link
Author

@firebird-automations
Copy link
Author

Modified by: @cincuranet

status: Open [ 1 ] => Closed [ 6 ]

resolution: Won't Fix [ 2 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants