lib/limits/estimates.js
function estimatedNumberOfRows(node, context, callback) {
    var sql = estimatedCountTemplate({
        sourceQuery: node.sql()
    });
    context.runSQL(sql, function(err, resultSet){
        var estimated_rows = null;
        if (!err) {
            if (resultSet.rows) {
                estimated_rows = resultSet.rows[0]['QUERY PLAN'][0].Plan['Plan Rows'];
            } else {
                // If we get no results (e.g. working with a fake db)
                // we make a most permissive estimate
                estimated_rows = 0;
            }
        }
        return callback(err, estimated_rows);
    });
}
function estimatedNumberOfRows(node, context, callback) {
    var sql = estimatedCountTemplate({
        sourceQuery: node.sql()
    });
    context.runSQL(sql, function(err, resultSet){
        var estimated_rows = null;
        if (!err) {
            if (resultSet.rows) {
                estimated_rows = resultSet.rows[0]['QUERY PLAN'][0].Plan['Plan Rows'];
            } else {
                // If we get no results (e.g. working with a fake db)
                // we make a most permissive estimate
                estimated_rows = 0;
            }
        }
        return callback(err, estimated_rows);
    });
}
function estimatedNumberOfRows ( node , context , callback ) { var sql = estimatedCountTemplate ( { sourceQuery : node . sql ( ) } ) ; context . runSQL ( sql , function ( err , resultSet ) { var estimated_rows = null ; if ( ! err ) { if ( resultSet . rows ) { estimated_rows = resultSet . rows [ 0 ] [ 'QUERY PLAN' ] [ 0 ] . Plan [ 'Plan Rows' ] ; } else { // If we get no results (e.g. working with a fake db) // we make a most permissive estimate estimated_rows = 0 ; } } return callback ( err , estimated_rows ) ; } ) ; }
Estimated number of rows in the result of a node. A LimitsContext object must be provided. This is an asynchronous method; an error object and the number of estimated rows will be passed to the callback provided. This uses PostgreSQL query planner and statistics; it could fail, returning a null count if no stats are available or if a timeout occurs.
Estimated number of rows in the result of a node . A LimitsContext object must be provided . This is an asynchronous method ; an error object and the number of estimated rows will be passed to the callback provided . This uses PostgreSQL query planner and statistics ; it could fail returning a null count if no stats are available or if a timeout occurs .