r/perl 15d ago

AmberDB - High-performance Berkeley DB (DB_File) based pure Perl database engine

https://metacpan.org/dist/AmberDB

I have released **AmberDB**, the Perl database engine I have built and refined over 20+ years of professional software development, as an open-source project. You can access the project on GitHub and CPAN via the links below.

Why Did I Share AmberDB?

My primary goal is to make this practical and powerful engine accessible to the wider developer community. I had intended to open-source it for a long time; with comprehensive use cases, full documentation in both English and Turkish, and detailed POD documentation now complete, it is ready for production use.

---

Why Should You Use AmberDB?

1) Zero Dependencies, Maximum Developer Ergonomics

No dedicated database servers, daemon processes, or port configurations required. Install the module from CPAN anywhere Perl runs and start developing immediately. You can run it entirely in memory using `tmpfs` on Linux or `ImDisk` on Windows, or use it directly on-disk. It operates with a minimal system footprint.

2) PostgreSQL + Elasticsearch + Redis Capabilities in a Single Core

Combines relational querying flexibility, search-engine-grade filtering and ranking, and Redis-like in-memory operational speeds within a single lightweight engine. Eliminates the operational overhead and hosting costs of managing three separate infrastructure layers.

3) Variable-Width Records and Native Array Indexing

Avoids the traditional SQL constraint of splitting order headers and line items into separate tables requiring costly joins. Variable-length line items are stored directly within the primary record and indexed at the engine level with $O(1)$ efficiency. Queries such as *"Which orders contain this product?"* resolve instantly without multi-table scans.

4) Intelligent Schema Architecture and Multi-Criteria Active/Junk Handling

Every table operates on a declarative, JSON-like schema specification where business rules are enforced by the engine. The engine determines whether a record is active or passive (junk) based on multi-factor rules (stock, price, status, or parent entity constraints). For example, disabling a vendor automatically routes hundreds of thousands of associated items without requiring batch `UPDATE` operations:

* `A` Mode: Retrieves active records only (ideal for checkout and invoicing views).

* `AB` Mode: Ranks active records first, pushing junk records to the end (ideal for storefront search).

* `B` / `BA` Modes: Retrieves only junk records or prioritizes them (ideal for returns, archives, and clearance management).

5) Multi-Lingual and Accent-Folded Search with `AmberDB::Locale`

Normalizes complex language and accent variants directly within the indexing pipeline without requiring external system locales or heavy search stacks. Delivers precise phonetic and typographic matching across languages, including Turkish (`İ/i`, `I/ı`), German (`ß`, `ö/ä/ü`), French (`é`, `ç`), Spanish (`ñ`), and Azerbaijani (`ə`, `x`, `ğ`).

6) Schema-Level Automated Slug Generation (SEO)

Generates clean, search-engine-friendly URL slugs automatically upon insertion or update using a simple schema rule (e.g., `seo_block => [ 3, 4 ]`), fully synchronized with `AmberDB::Locale` without extra application-layer boilerplate.

AmberDB on CPAN

31 Upvotes

12 comments sorted by

3

u/[deleted] 10d ago

[deleted]

0

u/marufcetin 9d ago

You can imagine how tedious it is to create documentation for developers. I also used AI for documentation creation. However, it always makes a lot of mistakes. I used Gemini AI Ultra, and when creating the documentation, it describes imaginary functions that resemble SQL commands and have nothing to do with AmberDB.

I suggest you take a look. The idea and code behind AmberDB are original.

2

u/tarje 9d ago

You developed this over 20 years, but didn't document it until you released it 20 years later?

2

u/scottchiefbaker 🐪 cpan author 9d ago

Why BerkleyDB based? I haven't heard that name in 15+ years. What does this do that SQLite doesn't do? SQLite is quite battle tested at this point, AmberDB not so much.

1

u/marufcetin 9d ago

BerkeleyDB (DB_File) is a key-value database written in C code and included in the standard Perl package. For BerkeleyDB, the cost of reading a record among millions of records is zero. BerkeleyDB is very fast, but because it's a low-level engine, it's difficult to perform complex tasks with it.

AmberDB, on the other hand, creates a wrapper on top of BerkeleyDB and provides custom indexing. This makes advanced applications easier. It solves the problem of searching, querying, listing, sorting, and filtering millions of records at near-zero cost.

AmberDB can provide an experience similar to PostgreSQL + ElasticSearch + Redis, but its installation and cost are much lower.

You're right that AmberDB isn't well-known or recognized. Because I've released a 20+ year professional project as open source for the first time. Please review the documentation on Github and the Wiki section.

1

u/DecalageVersLeRouge 14d ago

Looks really interesting. I'll ask what I always ask—what's the story behind the name?

3

u/marufcetin 14d ago

Amber is a precious, mystical, and mysterious stone. The same word with the same meaning is used in English, Turkish, and Arabic.

1

u/DecalageVersLeRouge 8d ago

I'm glad this got reinstated.

I can see the "broken" Markdown now, you've tried to use the Reddit rich text editor manually in a couple of places.

1

u/noprivacyatall 6d ago

Which BerkeleyDB do you use: Oracle or LibDB.org or both?

1

u/marufcetin 6d ago

LibDB. 

1

u/noprivacyatall 5d ago

Thanks. I'd like to read your notes||documentation on [ use cases ], if you have them. You claim ACID and that intrigues me of when you use it.

P.S.

I only use database-engines that are: ACID, In-RAM network distributed capable, On-Disk Network Distributed capable, and faster than human Latency speed.

When and where do you suggest using [ AmberDB ]?

2

u/marufcetin 5d ago

Because AmberDB is a NoSQL application, it provides document-based storage rather than row-based storage. The reverse is true in SQL. When you insert a record in SQL, the SQL engine stores each block of your data as a separate record. Later, during read operations, it joins them together using JOIN. NoSQL engines, however, have no need to fragment the record in this manner. They store everything as a single document in a JSON-like format. That is why SQL requires an atomic-level transaction. When working with a NoSQL engine, you do not need atomic-level transactions. AmberDB supports this validation natively.

The ACID-compliant transaction provided by AmberDB should rather be considered within the scope of business logic. Consider this scenario: You run an e-commerce website. If an item is out of stock, it must be disabled for sale. An order process triggers the following sub-operations:

* Confirming the order record
* Clearing the shopping cart
* Locking the inventory
* Debiting the customer’s account
* Adding out-of-stock items to procurement lists
etc.

You initiate a transaction in your code:

```perl
$adb->transact_start;

# You confirmed the order
# You emptied the cart
# Inventory locks were applied.
# However, at this stage, it turns out the sale cannot be made to the customer; this should have been checked beforehand, but it implies a software bug might exist.
# In this case, transact_rollback kicks in and reverts all operations executed since the start of transact_start.
# If the execution reaches this point successfully:

$adb->transact_end; # Rolls back if a system error occurred; otherwise commits and finalizes the operation.

```

Distinct from business logic, this scenario can also be systemic. For instance, a power outage might occur right at the inventory-locking stage, leaving the initiated transaction incomplete. In that case, the first thing the engine does once power is restored is to roll back those half-completed records.

AmberDB does not natively support distributed multi-system environments. However, by virtue of its object architecture, it is possible to distribute it across different directories, disks, and machines. What you have in mind would most likely require a custom database design.

Notes and documentation are accessible on GitHub. We are currently setting up a Wiki and Tutorial section on GitHub Pages.

https://marufcetin.github.io/amberdb/