I'd recommend trying VIDEX (Virtual Index for MySQL), which you can find on GitHub at https://github.com/bytedance/videx. It's an open-source project that introduces hypothetical index support to MySQL, similar to PostgreSQL's HypoPG.
VIDEX works by introducing a new storage engine that intercepts optimizer requests for statistics such as table rows, ndv (number of distinct values), and cardinality. These requests are then redirected to a Python-based statistics service. Although VIDEX is still in the early stages as an open-source project, it has shown promising results in benchmarks like TPC-H and JOB. With the oracle NDV and cardinality provided, the VIDEX query plan achieves 100% identity with that of InnoDB.
Additionally, VIDEX offers interfaces for NDV and cardinality estimation. If you are comfortable with Python, you can extend or reimplement these algorithms as needed.
For ease of use, you can try out VIDEX using Docker or by compiling it from source. It can be deployed either as a plugin or as a separate instance to ensure it does not impact your production environment.