I put together a simple test case:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=7, IE=9, IE=10">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title></title>
<link rel="stylesheet" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.4/js/esri/css/esri.css">
<style>
html, body, #map {
height: 100%; width: 100%; margin: 0; padding: 0;
}
#feedback {
background: #fff;
bottom: 30px;
color: #444;
position: absolute;
font-family: arial;
height: auto;
left: 20px;
margin: 5px;
padding: 10px;
bottom: 20px;
width: 200px;
z-index: 40;
}
</style>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/3.4/"></script>
<script>
var map;
require([
"dojo/dom", "dojo/on", "dojo/query",
"esri/map", "esri/layers/FeatureLayer", "esri/tasks/query",
"dojo/domReady!"
], function(dom, on, dojoQuery, Map, FeatureLayer, Query) {
map = new Map("map", {
basemap: "streets",
center: [-93.011, 44.951],
zoom: 11
});
var fl = new FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/1", {
id: "BlockGroups"
});
map.addLayer(fl);
// generate 10 random numbers < 200,000
var randoms = [];
for ( var i = 0; i < 10; i++ ) {
randoms.push(parseInt(Math.random() * 200000));
}
on(dom.byId("runQuery"), "click", function() {
var queryMethod = dojoQuery("input[name=queryType]:checked")[0].value;
var params = new Query();
params.returnGeometry = false;
if ( queryMethod === "where" ) {
// params.where = "OBJECTID IN (300, 301)";
params.where = "OBJECTID IN (" + randoms.join(",") + ")";
console.log("set params.where", params.where);
} else {
// params.objectIds = [ 300, 301 ];
params.objectIds = randoms
console.log("set params.objectIds", params.objectIds);
}
fl.queryFeatures(params).then(querySuccess, queryError);
});
function querySuccess(results) {
console.log("query success: ", results);
}
function queryError(error) {
console.log("query error: ", error);
}
}
);
</script>
</head>
<body>
<div id="map"></div>
<div id="feedback">
Query using:
<br>
<input type="radio" name="queryType" id="whereClause" value="where" checked="checked"><label for="whereClause">Where</label>
<input type="radio" name="queryType" id="objectIds" value="objectIds"><label for="objectIds">ObjectIds</label>
<br>
<button id="runQuery">Query</button>
</div>
</body>
</html>
That code is querying ten random features by OID from a layer with ~200k features (census block groups). Querying with .where or .objectIds takes the same amount of time. Can you repro your issue with the code above? Is this case similar to what you're doing? I would pursue this on the DB side to see what the different queries look like for query.where vs. query.objectIds.