a.pau

SE_stream_execute works slow if I use SE_stream_set_spatial_constraints

Discussion created by a.pau on Nov 25, 2013
Latest reply on Nov 29, 2013 by vangelo-esristaff
Hi,
I'm really worried about the behaviour of SE_stream_execute when I use SE_stream_set_spatial_constraints.
It seems that instead of saving time due to the constaints is taking the same amount of time than if they didn't exist.
The code I use is this (I avoid error managing to make it clearer and some unimportant things):

local int prepare_stream(SE_STREAM *stream,...)
{
SE_ENVELOPE rect;
SE_SHAPE mascara_shape;
SE_FILTER filter;
LONG    result;
SHORT num_cols, i_col, i_col_acum;
CHAR **columnes;
SE_SQL_CONSTRUCT sqlc;

        sqlc.where=NULL;

        //Use of 1 table
    sqlc.num_tables=1;
    if(NULL==(sqlc.tables=MM_calloc(sqlc.num_tables*sizeof(*(sqlc.tables)))))
        return -1;
    MM_strdup(&(sqlc.tables[0]), table);

        // Fill column names
    num_cols = ...
    columnes=MM_calloc(num_cols*sizeof(*(columnes)));
    if(NULL==columnes)
         return -1;
   
        // In a for...
    strdup(&(columnes[i_col]), name[i]);
   

    // Define the stream query
    result = pSE_stream_create (seConnection, stream);
       if(result != SE_SUCCESS)
           return -1;
   
        // Stream is passed to the function to be fetched after.
    result = pSE_stream_query (*stream, num_cols, (const CHAR **)columnes, &sqlc);
        if(result != SE_SUCCESS)
             -1;

    rect.minx=..;
    rect.maxx=..;
    rect.miny=...;
    rect.maxy=...;
   
    result = pSE_shape_create (coordref, &mascara_shape);
    if(result != SE_SUCCESS)
        return -1;

    result = pSE_shape_generate_rectangle(&rect, mascara_shape);
    if(result != SE_SUCCESS)
        return -1;
       
    memset(&filter, 0, sizeof(filter));
    strnzcpy(filter.table, table, SE_QUALIFIED_TABLE_NAME);
    strnzcpy(filter.column, column_shape_name, SE_MAX_COLUMN_LEN);
       
    filter.filter_type=SE_SHAPE_FILTER; // SE_SHAPE_FILTER , SE_ID_FILTER
    filter.filter.shape=mascara_shape;

    filter.truth=TRUE;
    filter.method=SM_ENVP;
    result = pSE_stream_set_spatial_constraints (*stream, SE_SPATIAL_FIRST, FALSE, 1, &filter);
    if(result != SE_SUCCESS)
         return -1;
    }
   
    result = pSE_stream_execute (*stream);
        if(result != SE_SUCCESS)
            return -1;
   
    if(sqlc.where)
        MM_free(sqlc.where);
        for(i_col=0;i_col<num_cols;i_col++)
        MM_free(columnes[i_col]);
    MM_free(columnes);
        MM_free(sqlc.tables[0]);
        MM_free(sqlc.tables);
}

It does work but it's very slow to take a few rows (like 20 or 30) in SE_stream_execute().
Anyone knows WHY? What can I do to make it quicker?

Note: think pSE_stream_execute as SE_stream_execute  (it's the pointer to the funtion)

Thanks for your answer!

Outcomes