0

This question is building off of a previous question I've asked before -- and while I resolved that issue by increasing FetchSize, I need to now change the query from SELECT * FROM TABLE1 to SELECT * FROM VIEW1, where TABLE1, and a couple of other tables in the database, are the base tables for VIEW1.

The code from the previous question is pretty much the same, but to account for the FetchSize change, breakpoints, and query:

Program.cs

class Program
{
    static void Main(string[] args)
    {
        // Create Connection
        OracleConnection con = new OracleConnection();

        // Create ConnectionString using Builder
        OracleConnectionStringBuilder ocsb = new OracleConnectionStringBuilder();
        ocsb.Password = "PASSWORD";
        ocsb.UserID = "USER1";
        ocsb.DataSource = "URL";

        // Connect 
        con.ConnectionString = ocsb.ConnectionString;
        con.Open();
        Console.WriteLine();
        Console.WriteLine(">>> Connection Established");

        // Execute a SQL SELECT
        OracleCommand cmd = con.CreateCommand();
            // Breakpoint #1
        cmd.CommandText = "select * from VIEW1";
            // Breakpoint #2 
        OracleDataReader reader = cmd.ExecuteReader();
        reader.FetchSize = 10 * 1024 * 1024;

        // Cache configuration
        var cfg = new IgniteConfiguration
        {
            PeerAssemblyLoadingMode = Apache.Ignite.Core.Deployment.PeerAssemblyLoadingMode.CurrentAppDomain,
            CacheConfiguration = new[]
            {
                new CacheConfiguration
                {
                    Name = "cacheName",
                    Backups = 1,
                    QueryEntities = new[]
                    {
                        new QueryEntity(typeof(int), typeof(Table))
                    }
                }
            }
        }

            // Breakpoint #3    
        IIgnite ignite = Ignition.Start(cfg);
        ICache<int, Table> cache = ignite.GetOrCreateCache<int, Table>("cacheName");

            // Breakpoint #4    
        using (var stmr = ignite.GetDataStreamer<int, Table>("cacheName"))
        {
            // Add entries to cacheName
            while (reader.Read())
            {
                Table table = new Table();
                table.SetObject(reader);
                stmr.AddData(table.Id, table.Name);
            }
            // Clean up
            // Breakpoint #5
            reader.Dispose();
            cmd.Dispose();
            con.Dispose();
        }
    }
}

Table.cs

class Table
    {
        [QuerySqlField(IsIndexed = true)]
        public int Id { get; set; }
        [QuerySqlField]
        public string Name { get; set; }

        public void SetObject(OracleDataReader reader)
        {
            Id = reader.IsDBNull(0) ? 0 : reader.GetInt32(0);
            Name = reader.IsDBNull(1) ? "" : reader.GetString(1);
        }
    }

View Definition

DROP VIEW USER1.VIEW1;

CREATE OR REPLACE FORCE VIEW USER1.VIEW1
(
    COL1,
    COL2,
    COL3,
    COL4,
    COL5,
    COL6,
    COL7
)
BEQUEATH DEFINER
AS
    SELECT a.col1,
           a.col2,
           a.col3,
           a.col4,
           a.col5,
           a.col6,
           a.col7
      FROM table1           a,
           table2          ph,
           (  SELECT col1,
                     SUM (DECODE (user_type, 'Top User', 0, 1))
                         team_count,
                     SUM (DECODE (user_type, 'Top User', 1, 0))
                         top_user_count
                FROM view2
            GROUP BY col1) gat
     WHERE     A.col3 = UPPER (PH.col3(+))
           AND a.col1 = gat.col1(+);


CREATE OR REPLACE SYNONYM USER2.VIEW1 FOR USER1.VIEW1;

CREATE OR REPLACE SYNONYM USER3.VIEW1 FOR USER1.VIEW1;


GRANT SELECT ON USER1.VIEW1 TO ID1;

GRANT SELECT ON USER1.VIEW1 TO ID2;

GRANT SELECT ON USER1.VIEW1 TO ID3;

GRANT SELECT ON USER1.VIEW1 TO ID4;

GRANT SELECT ON USER1.VIEW1 TO ID5;

Getting from breakpoint #1 to #2 is done in under a second. However, the time in between breakpoint #2 and breakpoint #3 was exceeding 30 minutes before my computer disconnected from the internet (there were no errors/exceptions prior to the disconnect as the program and diagnostic session were both running).

I was wondering if anyone could shed some light on why the program hangs on the line OracleDataReader reader = cmd.ExecuteReader();, and why this is an issue I face once I switched from TABLE to VIEW in my query.

0 Answers0