# Two SQL queries or a for loop with two arrays? (in terms of cpu usage)

**URL:** <https://forum.kirupa.com/t/two-sql-queries-or-a-for-loop-with-two-arrays-in-terms-of-cpu-usage/173975>\
**Category:** programming\
**Created:** [December 31, 2005, 9:15pm UTC](https://forum.kirupa.com/t/two-sql-queries-or-a-for-loop-with-two-arrays-in-terms-of-cpu-usage/173975 "2005-12-31T21:15:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cdunn](https://avatars.discourse-cdn.com/v4/letter/c/e68b1a/32.png) [@cdunn](https://forum.kirupa.com/u/cdunn)\
**Post date:** [December 31, 2005, 9:15pm UTC](https://forum.kirupa.com/t/two-sql-queries-or-a-for-loop-with-two-arrays-in-terms-of-cpu-usage/173975/1 "2005-12-31T21:15:57Z")

</div>

This is probabaly a pretty basic question but it has been on the back of my mind for awhile…

on a large scale, would it be more costly to execute two sql queries to get two arrays of data

or one query and sort the data after using foreach loops and such

Thanks!!
