NODE.JS + EXPRESS
POSTGRESQL + BLUEBIRD
MONGODB + MONGOOSEPOSTGRESQL :
function getAllCategory(req, res, next) {
db.any('SELECT * FROM pcategory WHERE isdeleted = FALSE')
.then(function(data) {
res.json({
status: 'success',
data: data,
message: 'GET all DATA'
});
})
.catch(function(err) {
return next(err);
});
}
GET /api/v1/category/ 200 6.460 ms - 191
GET /api/v1/category/ 200 3.310 ms - 191
GET /api/v1/category/ 200 3.850 ms - 191
GET /api/v1/category/ 200 2.459 ms - 191
GET /api/v1/category/ 200 2.598 ms - 191
GET /api/v1/category/ 200 4.042 ms - 191
GET /api/v1/category/ 200 3.694 ms - 191
GET /api/v1/category/ 200 2.319 ms - 191
GET /api/v1/category/ 200 2.611 ms - 191
GET /api/v1/category/ 200 2.227 ms - 191
GET /api/v1/category/ 200 2.698 ms - 191
MONGODB:function getAllCategory(req, res, next) {
model.CategoryModel.find({$where:"this.isDeleted == false"}, function(err, category) {
if (err) return next(err);
res.json(category);
});
}
GET /api/v2/category/ 200 43.354 ms - 32230
GET /api/v2/category/ 200 99.844 ms - 32230
GET /api/v2/category/ 200 55.187 ms - 32230
GET /api/v2/category/ 200 49.486 ms - 32230
GET /api/v2/category/ 200 65.210 ms - 32230
GET /api/v2/category/ 200 51.937 ms - 32230
GET /api/v2/category/ 200 45.078 ms - 32230
GET /api/v2/category/ 200 50.517 ms - 32230
POSTGRESQL:
function getAllImageFromCategory(req, res, next) {
db.any(
`SELECT p.image_id, p.image_title, p.image_url, p.rating, p.desc_short, p.desc_full FROM pcategory
JOIN nn_category_image nn
ON nn.pcategory_id = pcategory.pcategory_id
JOIN image p
ON nn.image_id = p.image_id
WHERE pcategory.pcategory_id =${req.params.category_id} AND p.isdeleted = FALSE`)
.then(function(data) {
res.json({data: data});
})
.catch(function(err) {
return next(err);
});
}
GET /api/v1/category/1/image 200 7.692 ms - 25232
GET /api/v1/category/1/image 200 7.433 ms - 25232
GET /api/v1/category/1/image 200 8.680 ms - 25232
GET /api/v1/category/1/image 200 8.676 ms - 25232
GET /api/v1/category/1/image 200 5.980 ms - 25232
GET /api/v1/category/1/image 200 9.330 ms - 25232
GET /api/v1/category/1/image 200 9.242 ms - 25232
GET /api/v1/category/1/image 200 9.438 ms - 25232
GET /api/v1/category/1/image 200 8.978 ms - 25232
MONGODB:
function getAllImageFromCategory(req, res, next) {
model.CategoryModel.findById(req.params.category_id, function(err, category) {
if (err) {
return res.json({ message: err.message });
}
res.json(category.image);
});
}
GET /api/v2/category/578706e28862784508cb7a1b/image 200 62.497 ms - 31312
GET /api/v2/category/578706e28862784508cb7a1b/image 200 82.299 ms - 31312
GET /api/v2/category/578706e28862784508cb7a1b/image 200 74.558 ms - 31312
GET /api/v2/category/578706e28862784508cb7a1b/image 200 50.366 ms - 31312
GET /api/v2/category/578706e28862784508cb7a1b/image 200 65.073 ms - 31312
GET /api/v2/category/578706e28862784508cb7a1b/image 200 45.323 ms - 31312
GET /api/v2/category/578706e28862784508cb7a1b/image 200 48.513 ms - 31312
GET /api/v2/category/578706e28862784508cb7a1b/image 200 53.180 ms - 31312
И все это на localhost.
Скажите так должно быть или нужно на монге запросы как-то иначе писать?
Да у меня и на postgreSQL то не ахти какие запросы получились, а вот время прям в разы отличается.