Maximum Document Id - ravendb

If I insert a User into the Users collection and it's the first document RavenDB might assign it an id of users/1.
If the id field is a string and the maximum length of the id field is 1023, what is the limit on how far these automatically assigned ids can grow? Is there an upper limit like maxint? i.e. users/2147483647.

The numeric is is a long. That gives you 9,223,372,036,854,775,807 distinct ids.

Related

How to return all records where id contains a certain sequence of some digits PostgreSQL query

I have a query that brings back a value based on the user id. The id is int8. How could I make the query to return all the records that contain a certain sequence of the numbers, in other words.
the full user id presented as..
where up.user_id in (7401195021087888999)
and then where u only have a segment of the user id
where up.user_id Contains(74011950210878)
to bring back several records (hopefully). Contains is not correct, just to explain.
Hope this makes sense
One option would be to cast the integer column to text and then use LIKE:
SELECT *
FROM yourTable
WHERE user_id::text LIKE '%74011950210878%';
Note that your requirement might imply that the user_id column should actually be a text column, and not numeric.

in sql in a table, in a given column with data type text, how can we show the rest of the entries in that column after a particular entry

in sql, in any given table, in a column named "name", wih data type as text
if there are ten entries, suppose an entry in the column is "rohit". i want to show all the entries in the name column after rohit. and i do not know the row id or id. can it be done??
select * from your_table where name > 'rohit'
but in general you should not treat text columns like that.
a database is more than a collection of tables.
think about how to organize your data, what defines a datarow.
maybe, beside their name, there is another thing how you would classify such a row? some things like "shall be displayed?" "is modified" "is active"?
so if you had a second column, say display of type int and your table looked like
CREATE TABLE MYDATA
NAME TEXT,
DISPLAY INT NOT NULL DEFAULT(1);
you could flag every row with 1 or 0 whether it should be displayed or not and then your query could look like
SELECT * FROM MYDATA WHERE DISPLAY=1 ORDER BY NAME
to get your list of values.
it's not much of a difference with ten rows, you don't even need indexes here, but if you build something bigger, say 10,000+ rows, you'd be surprised how slow that would become!
in general, TEXT columns are good to select and display, but should be avoided as a WHERE condition as much as you can. Use describing columns, preferrably int fields which can be indexed with extreme high efficiency and an application doesn't get slower even if the record size goes over 100k.
You can use "default" keyword for it.
CREATE TABLE Persons (
ID int NOT NULL,
name varchar(255) DEFAULT 'rohit'
);

Redis sorted sets

I have a list of Ids from a table that I want to store in a Redis sorted set. Each of these ids has a date and entity associated with it. The plan is to use the id as the score and allow Redis to sort them accordingly. When it is time for lookup I will get the max id and the min id from the table by start and end dates. Using this min and max id I can get a list of ids between them using Redis' zrangebyscore command.
entities' values = zrangebyscore ids (min max
Since the ids are sorted numerically I can reliably get all the ids belonging to my entity between two dates(min id and max id). My question is when creating my sorted set I do not know what to enter for the value in "key score value".
zadd key score value
When I create the list I do not have any information that fits well for the "value" parameter. Can this be blank or some arbitrary id?
zadd ids 123 ???
I am still rather new to Redis and any info on the subject would be greatly appreciated.
Thank you
You don't need Sorted Sets, you just need a Set:
1. define a key that is something like: entity1:ids
2. add your ids to this key
Use SADD entity1:ids 1 to add and SMEMBERS and SUNION to retrieve all the ids for one entity or the union of multiple entities, doc here.

Can column values be accessed like an array in SQL server

Can column values be accessed like an array in SQL server. for instance Select x[1] from tableA gives me the value for that field. I'm attempting to do this #OldValue = (SELECT #fieldname FROM #del). But this just returns the actual field name not the field value
No. Data in tables is not ordered, so there is no first, second, etc. record. You access a record by some criteria, e.g. a user by a user ID or login name, an employee by an employee number, etc. Or you use technical IDs to access records.
If you want the fifth record according to some order you can usually use some limit clause. E.g.:
SELECT *
FROM user
ORDER BY userid
OFFSET 4 ROWS FETCH NEXT 1 ROW ONLY;
fetches the 5th record ordered by user ID.
As to columns: They are accessed by their names. E.g.:
SELECT name
FROM user
ORDER BY userid
OFFSET 4 ROWS FETCH NEXT 1 ROW ONLY;
As you see it would make no sense to have some Excel-like access, because you need an order by clause and accessing columns via name rather than by some letter or number is even more readable and less prone to errors.

How does Oracle perform read operation?

Suppose we have a table which holds information about person. Columns like NAME or SURNAME are small (I mean their size isn't very large), but columns that hold a photo or maybe a person's video (blob columns) may be very large. So when we perform a select operation:
select * from person
it will retrieve all this information. But in most cases we need only retrieve name or surname of person, so we perform this query:
select name, surname from person
Question: will Oracle read the whole record (including the blob columns) and then simply filter out name and surname columns, or will it only read name and surname columns?
Also, even if we create a separate table for such large data(person's photo and video) and have a foreign key to that table in person's table and want to retrieve only photo, so we perform this query:
select photo
from person p
join largePesonData d on p.largeDataID = d.largeDataID
where p.id = 1
Will Oracle read a whole record in person table and whole record in largePesonData or will it simply read the column with photo in largePesonData?
Oracle reads the data in blocks.
Let's assume that your block size is 8192 bytes and your average row size is 100 bytes - that would mean each block would populate 8192/100 = 81 rows (It's not accurate since there is some overhead coming from the block header - but I'm trying to keep things simple).
So when you
select name, surname from person;
You actually retrieve at least on block with all of it's data (81 rows), and later after it is being screened returning you only the data you requested.
Two exceptions to this are:
BLOB Column - "select name, surename from person" will not retrieve the BLOB contents itself because BLOB columns contain a reference to the actual BLOB (which sits somewhere else on the tablespace or even in anoter TS)
Indexed columns - In case you created an index on the table using the columns name and surname it is possible that Oracle will only scan this specific index and retrieve only those two columns.