2011-07-15

Force.com : 取引先(Account)のレコードを 200 件以上取得したい


取引先(Account)のレコードを 200 件以上取得したい



ここ] 見れば解決。
でも、試してみる。



○ 取引先(Account)のレコードを 200 件以上取得したい

@isTest
private class Test {
    static testMethod void test() {

        String log = '\n********** ********** ********** ********** ********** ';

        Integer accountCount1 = [SELECT COUNT() FROM Account];
        log += '\naccount count 1: ' + accountCount1.format();

        for(Integer i=0; i<5; i++) {
            List<account> iaccounts = new List<account>();
            for(Integer j=0; j<200; j++) {
                iaccounts.add(new Account(Name=(i * j).format()));
            }
            insert iaccounts;
        }
        Integer accountCount2 = [SELECT COUNT() FROM Account];
        log += '\naccount count 2: ' + accountCount2.format();

        Integer countA = 0;
        Integer countB = 0;
        for(List<account> accounts : [SELECT Id, Name FROM Account]) {
            countA++;
            for(Account account : accounts) {
                countB++;
            }
        }
        log += '\ncount A: ' + countA.format();
        log += '\ncount B: ' + countB.format();
        log += '\n********** ********** ********** ********** ********** ';

        System.debug(log);
    }
}
デバッグログ
22.0 APEX_CODE,FINE;APEX_PROFILING,FINE;DB,INFO;VALIDATION,INFO;WORKFLOW,FINEST
18:27:24.062 (62635000)|EXECUTION_STARTED
18:27:24.062 (62764000)|CODE_UNIT_STARTED|[EXTERNAL]|01pA0000002xdKd|Test.test
18:27:24.062 (62881000)|METHOD_ENTRY|[2]|01pA0000002xdKd|Test.Test()
18:27:24.062 (62955000)|METHOD_EXIT|[2]|Test
18:27:24.063 (63095000)|SOQL_EXECUTE_BEGIN|[7]|Aggregations:0|SELECT COUNT() FROM Account
18:27:24.081 (81325000)|SOQL_EXECUTE_END|[7]|Rows:22
18:27:24.130 (130766000)|DML_BEGIN|[15]|Op:Insert|Type:Account|Rows:200
18:27:25.124 (1124205000)|DML_END|[15]
18:27:25.180 (1180964000)|DML_BEGIN|[15]|Op:Insert|Type:Account|Rows:200
18:27:26.274 (2274698000)|DML_END|[15]
18:27:26.319 (2319497000)|DML_BEGIN|[15]|Op:Insert|Type:Account|Rows:200
18:27:27.406 (3406968000)|DML_END|[15]
18:27:27.451 (3451056000)|DML_BEGIN|[15]|Op:Insert|Type:Account|Rows:200
18:27:28.853 (4853143000)|DML_END|[15]
18:27:28.896 (4896512000)|DML_BEGIN|[15]|Op:Insert|Type:Account|Rows:200
18:27:30.000 (6000677000)|DML_END|[15]
18:27:30.001 (6001131000)|SOQL_EXECUTE_BEGIN|[17]|Aggregations:0|SELECT COUNT() FROM Account
18:27:30.020 (6020864000)|SOQL_EXECUTE_END|[17]|Rows:1022
18:27:30.021 (6021130000)|SOQL_EXECUTE_BEGIN|[22]|Aggregations:0|SELECT Id, Name FROM Account
18:27:30.144 (6144360000)|SOQL_EXECUTE_END|[22]|Rows:1022
18:27:30.303 (6303727000)|USER_DEBUG|[32]|DEBUG|
********** ********** ********** ********** **********
account count 1: 22
account count 2: 1,022
count A: 6
count B: 1,022
********** ********** ********** ********** **********
18:27:30.808 (6303844000)|CUMULATIVE_LIMIT_USAGE
18:27:30.808|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 3 out of 100
Number of query rows: 2066 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 5 out of 150
Number of DML rows: 1000 out of 10000
Number of script statements: 2055 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

18:27:30.808|TOTAL_EMAIL_RECIPIENTS_QUEUED|0
18:27:30.808 (6303844000)|CUMULATIVE_LIMIT_USAGE_END

18:27:30.303 (6303947000)|CODE_UNIT_FINISHED|Test.test
18:27:30.303 (6303976000)|EXECUTION_FINISHED
18:27:32.455|CUMULATIVE_PROFILING_BEGIN
18:27:32.455|CUMULATIVE_PROFILING|No profiling information for SOQL operations
18:27:32.455|CUMULATIVE_PROFILING|No profiling information for SOSL operations
18:27:32.455|CUMULATIVE_PROFILING|No profiling information for DML operations
18:27:32.455|CUMULATIVE_PROFILING|No profiling information for method invocations
18:27:32.455|CUMULATIVE_PROFILING_END



◇ 環境

  • Salesforce - Developer Edition - API バージョン 22.0



◇ 参考


0 件のコメント:

コメントを投稿