logs archiveIRC Archive / Freenode / #php / 2015 / July / 30 / 1
cquilty
I just had an idea. Is it bad to make a boolean database table column NOT NULL and DEFAULT false? As in, will it require more storage space and make it slower on huge tables, compared to making it default to null and then only set true for those you want?
Naktibalda
cquilty: default NULL could use more space
runinsquares
Alphos, would you need to do something like set up a logfile for incorrect GUI logins and tell fail2ban to monitor that? (probably a stupid question)
Alphos
cquilty i'd avoid using NULL instead of false if i were you. also, even on very large tables (1000Mrow and more), i think i wouldn't care about the tiny byte i'd add per row
runinsquares you'd have to ask people who support fail2ban, i'm not really savvy enough in it to make a probative answer
cquilty NULL values in your table are just going to make your life miserable. don't use them unless you want them to be NULL values. don't use NULL values to represent something else
cquilty
Alphos: On very large tables, isn't that where it matters the most?
Ah.
Well, you've convinced me to stick to default FALSE and no nulls for booleans.
fabienwang
Do you guys know a MQ script written in PHP ?
cquilty
Although I'm confused about what Naktibalda said about NULL using more space than FALSE.
And also what Alphos said about how he wouldn't care when the table is really big, where it should matter the most.
Alphos
cquilty if you have a billion rows in there, it's still not going to take more than a few GB (if it does take bytes at all), and you shouldn't worry about it
cquilty but as a general rule, use the values that make sense, not values that may seem like they'll spare you a few bytes here and there
on very large tables, a few GB more or less is not going to matter on your hard drive. but it may save the hair you won't be pulling when turning mad
Naktibalda
cquilty: are you asking about mysql?
         

cquilty
Naktibalda: PostgreSQL.
Alphos: I guess I don't follow the logic with it not mattering on huge tables.
Although I agree that I should use the values I need.
And not trying to think of how the DB stores it.
Naktibalda
cquilty: http://stackoverflow.com/questions/5008753/does-not-using-null-in-postgresql-still-use-a-null-bitmap-in-the-header
Alphos
cquilty because on larger tables, you stop worrying about space you have, since it's not relevant anymore
cquilty note that larger tables shoot up to terabytes
Majeh
fabienwang what kind of MQ are you after?
what's the problem that you have which MQ solves?
fabienwang
potentially long running processes on a server
I don't want to use php script with unlimited runtime.
Majeh
err.. then how will you implement the queue if it's not a long running process?
you can always use zeromq with php
NoiseEee
fabienwang: whats the larger issue you're trying to solve
Majeh
though, it depends on your need on what you'll do. a daemon in php with zmq can act as a perfectly good mq
Alphos
i'm guessing he doesn't want php to run the service, but to add messages to the queue
fabienwang
the problem is I don't want the clients to wait, I want to inform them (using a notification or smtg coming back to them) once it's done.
NoiseEee
fabienwang: what are they waiting for
Alphos
fabienwang if you don't want them to wait, why do you want to use a message queue at all ?
NoiseEee
fabienwang: anyways, consider gearman as well.
fabienwang
for example they want a backup of their database or website, i'm gonna compress it for them then send it.
NoiseEee
php -> sends job to gearman -> no waiting; gearman job complete? gearman notifies php (or node, or whatever)
Dr-007
good evening. simple question; i've got 2 arrays with objects inthere. the arrays are both indexed from 0 to 3. when doing $result += $new_arr; alle items should be in the $result array right?
NoiseEee
Dr-007: if only there was a way to tell
Dr-007
yeah they arent all inthere
thats why i'm confused
but += is the right way of adding stuff to an array right
Alphos
not really, no
$array[] would be
Majeh
fabienwang there are literally thousands of ways to do that. you can have the classic save the job to a db > use cron to check it every now and then and then execute the script that does the task (kind of sucks) or you can resort to gearman as suggested
         

Dr-007
Alphons, but then i would have to iterate trough my arrays first
NoiseEee
Dr-007: sounds like you want to merge the arrays http://3v4l.org/p61aC
runinsquares
http://php.net/manual/en/language.operators.array.php
Majeh
if i had to develop something like that from scratch, i'd use a simple php daemon that performs the task. the script sends the job, doesn't wait for the reply, sends the http response back to the user
Alphos
Dr-007 yes you would. alternatively, you can look into array functions and operators to find out what they do
fabienwang how big do you expect the databases and sites to be ?
Gatomon
Majeh, sounds like he's queuing. Not scheduling.
Majeh
Gatomon sounds like he needs a job queue that does something when needed. i'm just throwing ideas out until the exact problem comes up
Dr-007
NoiseEee, thanks. i keep forgetting that one
fabienwang
the only problem is I don't see how to send back a notification to the user once a task is complete.
Alphos
fabienwang again, how big do you expect them to be ?
fabienwang
500M at most Alphos
Majeh
email, web sockets, sms
fabienwang
which could take up to 5 minutes to do I guess
Alphos
fabienwang ok, that's already a bit too big for what i had in mind
fabienwang
yeah websockets nice idea Majeh
I could try that
Alphos
fabienwang you don't want to handle websockets with php
Majeh
mongrel2, node.js
Alphos
but with that caveat in mind, sure, go ahead :)
Majeh
again, many solutions are out there, it all depends how quickly you need the solution implemented. i would concede that node is the quickest way to make it work though
NoiseEee
fabienwang: i use php/gearman/node quite successfully.
(where node handles the websocket notification)
Alphos
NoiseEee if the code is available somewhere, i'd be delighted to see it
fabienwang
Same :)
Majeh
i must be the only one using mongrel2 for it :/
NoiseEee
well i think its pretty standardish... need gearmand and the pecl gearman extension
when the gearman job is finished, it calls a "node" php class which essentially is a curl call to a node server... notification is sent
can't exactly paste code though aside from this fairly simple thing https://gist.github.com/NoiseEee/2b88e9d3774d9c48da77
fabienwang
k i'm gonna test all that, thx again NoiseEee & Majeh
& you too Alphos :)
Alphos
don't mention it :)
NoiseEee not a gearman user myself, i find the idea of it calling php to perform a request on a node instance weird
NoiseEee
well the browsers are using websockets via socket.io (node)
Alphos
yes, but can't node be notified directly ?
NoiseEee
and so to notify them that things are complete on the backend, basically just an http request to that node server / namespace
Alphos: sure, i just use PHP to encode the data payload / anything that node might need to parse and send as variables to the JS
Alphos
because if i understand this right, you still need to have something start running a php script out of the blue to check if gearman finished its task, then probe node if it has
(not criticizing, trying to understand gearman, really ^^' )
NoiseEee
what do you mean by 'something start running a php script...'
you mean a gearman 'worker' ?
Alphos
NoiseEee so a gearman worker will run a php script that has the "node php class" (or instance thereof) you were talking about, right ?
NoiseEee
right, and yes, that worker is always listening/waiting for a job
Alphos
isn't there a way to bind it to the node instance directly ?
NoiseEee
well my gearman task is written in php
and the only way i can connect/notify node is via an http request (i'm using curl in that example for it, but could have done anything else)
Alphos
bit of a shame that gearman can't do it directly
i'd half-expect some npm package to be able to accept messages from the MQ
NoiseEee
or, another way to say it perhaps, is that my node server is awaiting requests as well... http://someURL:port/myNodeApp
Alphos
yes, but it'd be so clean if it didn't have to go through http....
NoiseEee
i don't think that I have to, but I use express
plus this way I can test responses from the node app by using a REST client, etc
Alphos
NoiseEee
oh i'll look into that; the one thing ive left out is that the gearman worker/server is actually on a different machine on the network
« prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 next »