Editing
Architecture decision records
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== 4. ADR-003 β Divisors Stored in Database == '''Date:''' 2025 (inferred)<br /> '''Status:''' Accepted<br /> '''Deciders:''' Original developer<br /> '''Source:''' [INFERRED from algorithm and SQL design] <span id="context-2"></span> === Context === The trial-division sieve needs a list of previously found primes to use as divisors. These could be held in a COBOL working-storage table (an array), in a flat file, or in the database. <span id="decision-drivers-2"></span> === Decision Drivers === * Demonstrate database interaction as part of the algorithm (pedagogical goal). * Keep the COBOL working-storage footprint small β avoid a large in-memory prime array. * Persist divisors so the report can run independently of the generation run. <span id="options-considered-2"></span> === Options Considered === {| !width="24%"| Option !width="39%"| Description !width="18%"| Pros !width="18%"| Cons |- | A | In-memory COBOL table | Fastest; no I/O | Fixed size; lost between runs; defeats the DB demonstration goal |- | B | Flat file | Persistent; simple | Requires file I/O; not the DB demonstration goal |- | C | Database (chosen) | Persistent; demonstrates DB use; divisors and output in same store | One SQL query per trial division step β potentially very slow |} <span id="decision-2"></span> === Decision === Option C β each divisor is fetched from the <code>primes</code> table by ident using a point SELECT. Generated primes accumulate in the same table as the divisors. <span id="consequences-2"></span> === Consequences === '''Positive:''' - Demonstrates the full three-tier pattern end-to-end. - All state is in the database; generation can be interrupted and (in principle) resumed. '''Negative / trade-offs:''' - Performance is heavily dependent on the <code>SELECT prime WHERE ident = :n</code> query. Without an index on <code>ident</code>, this becomes a sequential scan that gets slower as the table grows. - The design requires prime 2 to be pre-seeded in the table before the algorithm starts, since the first divider fetch assumes ident=2 exists. '''Risks:''' - No index on <code>ident</code> is defined in <code>primes_schema.sql</code> (see NFR-PERF-03). This is the most significant performance risk in the system. <span id="compliance-check-2"></span> === Compliance check === Run <code>\d primes.primes</code> in psql; verify an index on <code>ident</code> is present. If absent, add: <code>CREATE INDEX idx_primes_ident ON primes.primes (ident);</code> ----- <span id="adr-004-gixsql-as-sql-pre-processor"></span>
Summary:
Please note that all contributions to Webhuis wiki are considered to be released under the GNU Free Documentation License 1.3 or later (see
Project:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Voorpagina
Cobol and PostgreSQL
PostgreSQL
CFEngine
Proxmox
Webhuis Kennisbank
Basale infra
Webhuis bouwstenen
Webhuis configuratie
Webhuis Infra
Webhuis Support
Webhuis Raspberry
Opzet Applicaties
Business Applicaties
Community portal
Current events
Recent changes
Random page
Help
sitesupport
Tools
What links here
Related changes
Special pages
Page information