Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3235908
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:33:38+00:00 2026-05-17T17:33:38+00:00

I have some pretty complex reports to write. Some of them… I’m not sure

  • 0

I have some pretty complex reports to write. Some of them… I’m not sure how I could write an sql query for just one of the values, let alone stuff them in a single query.

Is it common to just pull a crap load of data and figure it all via code instead? Or should I try and find a way to make all the reports rely on sql?

I have a very rich domain model. In fact, parts of code can be expanded on to calculate exactly what they want. The actual logic is not all that difficult to write – and it’s nicer to work my domain model than with SQL. With SQL, writing the business logic, refactoring it, testing it and putting it version control is a royal pain because it’s separate from your actual code.

For example, one the statistics they want is the % of how much they improved, especially in relation to other people in the same class, the same school, and compared to other schools. This requires some pretty detailed analysis of how they performed in the past to their latest information, as well as doing a calculation for the groups you are comparing against as a whole. I can’t even imagine what the sql query would even look like.

The thing is, this % improvement is not a column in the database – it involves a big calculation in of itself by analyzing all the live data in real-time. There is no way to cache this data in a column as doing this calculation for every row it’s needed every time the student does something is CRAZY.

I’m a little afraid about pulling out hundreds upon hundreds of records to get these numbers though. I may have to pull out that many just to figure out 1 value for 1 user… and if they want a report for all the users on a single screen, it’s going to basically take analyzing the entire database. And that’s just 1 column of values of many columns that they want on the report!

Basically, the report they want is a massive performance hog no matter what method I choose to write it.

Anyway, I’d like to ask you what kind of solutions you’ve used to these kind of a problems.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:33:39+00:00Added an answer on May 17, 2026 at 5:33 pm

    Sometimes a report can be generated by a single query. Sometimes some procedural code has to be written. And sometimes, even though a single query CAN be used, it’s much better/faster/clearer to write a bit of procedural code.

    Case in point – another developer at work wrote a report that used a single query. That query was amazing – turned a table sideways, did some amazing summation stuff – and may well have piped the output through hyperspace – truly a work of art. I couldn’t have even conceived of doing something like that and learned a lot just from readying through it. It’s only problem was that it took 45 minutes to run and brought the system to its knees in the process. I loved that query…but in the end…I admit it – I killed it. ((sob!)) I dismembered it with a chainsaw while humming “Highway To Hell”! I…I wrote a little procedural code to cover my tracks and…nobody noticed. I’d like to say I was sorry, but…in the end the job ran in 30 seconds. Oh, sure, it’s easy enough to say “But performance matters, y’know”…but…I loved that query… ((sniffle…)) Anybody seen my chainsaw..? >;->

    The point of the above is “Make Things As Simple As You Can, But No Simpler”. If you find yourself with a query that covers three pages (I loved that query, but…) maybe it’s trying to tell you something. A much simpler query and some procedural code may take up about the same space, page-wise, but could possibly be much easier to understand and maintain.

    Share and enjoy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an application that relies on some pretty interesting and complex MS SQL
Just writing some CSS and I have a pretty cool Search form where you
I have a hopefully pretty simple question here. I'm converting some Access SQL script
This is a pretty complex MySQL query for me. what i have is a
I have some pretty big xml files which used for scheduled import. I use
I have some DataGrids with pretty standard one-line itemrenderers, but need to use a
These are probably are pretty simple YES|NO type questions. I have some NSDictionaries containing
I have been doing some research on test driven development and find it pretty
I have a pretty simple UIScrollView defined inside Interface Builder. I've pasted in some
Pretty simple question. I have a few ASP RequiredFieldValdators checking some text boxes. Out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.