Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem using "real" datatype in PostgreSQL. #72

Open
dimag1978 opened this issue Jul 3, 2023 · 1 comment
Open

Problem using "real" datatype in PostgreSQL. #72

dimag1978 opened this issue Jul 3, 2023 · 1 comment

Comments

@dimag1978
Copy link

dimag1978 commented Jul 3, 2023

When pisces creates database tables, the type used for non-integer fields is real. For example, this is a table - Origin:

CREATE 
TABLE IF NOT EXISTS origin
(
    lat real,
    lon real,
    depth real,
...

The use of this data type causes problems with accuracy and with the search for events at given coordinates.
For example I have an event with coordinates lat: 41.0508 lon:79.5898. I am running a query:

SELECT * FROM origin WHERE lat=41.0508 AND lon=79.5898;

which returns nothing.
If I manually change the real data type to numeric, then I find the desired event.
Floating point variables are vulnerable to floating point errors. Therefore, if accuracy is important it's always recommended to use a numeric type.

@jkmacc-LANL
Copy link
Member

Thanks for all your feedback. This is helpful. I was trying to choose data types that were generic, but ultimately resolved the the ones used by my team. Your solution may be a better one; let me see how numeric works with our backend and I'll try to respond quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants